Prometheus
Monitor NodeLink's performance in production
Prometheus
NodeLink exposes Prometheus metrics out of the box. No plugins, no extra setup, just detailed observability into your audio streaming performance.
What you get
Production metrics that matter:
Audio Quality
Frame delivery rates, nulled frames, deficit tracking
Memory Breakdown
RSS, heap usage, external buffers, V8 spaces
Runtime Health
Event loop lag, GC pauses, CPU load
System Resources
File descriptors, active handles, API traffic
Quick setup
⚠️ Optional Dependency Required
Prometheus metrics require the prom-client package to be installed:
npm install prom-clientWithout this package, NodeLink will throw an error if metrics are enabled in your configuration. You can disable metrics by setting metrics.enabled: false in your config file.
Configure metrics
Metrics are enabled by default. Set your authorization in config.js:
export default {
options: {
metrics: {
enabled: true,
authorization: {
type: 'Bearer',
password: 'your_secret_here'
}
}
}
}If you leave the password empty, NodeLink uses your server password instead.
Test the endpoint
curl -H "Authorization: Bearer your_secret_here" \
http://localhost:2333/v4/metricsYou should see:
# HELP nodelink_playing_players Number of active audio players
# TYPE nodelink_playing_players gauge
nodelink_playing_players 5
# HELP nodelink_frames_sent Audio frames sent to Discord
# TYPE nodelink_frames_sent counter
nodelink_frames_sent 150234Add to Prometheus
Edit your prometheus.yml:
scrape_configs:
- job_name: 'nodelink'
scrape_interval: 15s
static_configs:
- targets: ['localhost:2333']
metrics_path: '/metrics'
authorization:
type: Bearer
credentials: 'your_secret_here'Reload Prometheus:
curl -X POST http://localhost:9090/-/reloadGrafana dashboard
We built a complete dashboard template for quick deployment.

What's included
Real-time audio health with active players, frame rates, and CPU load. Memory anatomy showing RSS vs heap vs external buffers. V8 heap space breakdown for new, old, code, and large objects. Event loop lag percentiles and GC pause heatmap. Frame delivery comparison and quality loss tracking.
Import to Grafana
Import it in Grafana:
- Go to Dashboards → Import
- Paste the JSON or upload the file
- Select your Prometheus datasource
- Done
The dashboard uses two template variables:
$datasource- Your Prometheus instance$job- Job name filter (supports multi-select)
Metric Categories
Example Queries
Audio Quality
| Metric | Type | Description |
|---|---|---|
nodelink_playing_players | Gauge | Active players streaming audio |
nodelink_frames_sent | Counter | Successfully delivered audio frames |
nodelink_frames_expected | Counter | Frames expected (3000/min per player) |
nodelink_frames_nulled | Counter | Empty frames sent |
nodelink_frames_deficit | Gauge | Difference between expected and sent |
Keep deficit near 0 for smooth audio. Spikes indicate stuttering.
Alerting Rules
Example rules for production monitoring.
Audio Degradation
groups:
- name: nodelink_audio
interval: 30s
rules:
- alert: HighFrameDeficit
expr: nodelink_frames_deficit > 100
for: 1m
labels:
severity: warning
annotations:
summary: "Audio quality degraded"
- alert: FrequentNulledFrames
expr: rate(nodelink_frames_nulled[5m]) > 5
for: 2m
labels:
severity: critical
annotations:
summary: "High nulled frame rate"Performance Issues
- alert: HighEventLoopLag
expr: nodejs_eventloop_lag_p99_seconds > 0.1
for: 2m
labels:
severity: warning
- alert: MemoryLeakSuspected
expr: |
(nodejs_heap_size_used_bytes - nodejs_heap_size_used_bytes offset 1h)
/ nodejs_heap_size_used_bytes offset 1h > 0.5
for: 30m
labels:
severity: warningEvent loop lag above 100ms causes audio stuttering and API slowdowns.
Pro Tips
Frame deficit should stay within ±50. Large spikes need immediate investigation.
External memory grows with active players. Each player holds decoded audio buffers, this is normal behavior.
Watch for GC pauses over 100ms. Frequent long pauses mean you should increase heap size or reduce player count.
Event loop lag spikes indicate blocking code. Use Node.js profiler to find synchronous bottlenecks.
Use recording rules to pre-aggregate expensive queries:
- record: nodelink:frame_delivery_rate
expr: rate(nodelink_frames_sent[5m])For retention beyond 2 weeks, consider pairing Prometheus with Thanos or Cortex.