NodeLink
Advenced

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-client

Without 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/metrics

You 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 150234

Add 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/-/reload

Grafana dashboard

We built a complete dashboard template for quick deployment.

NodeLink Grafana Dashboard

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:

  1. Go to DashboardsImport
  2. Paste the JSON or upload the file
  3. Select your Prometheus datasource
  4. Done

The dashboard uses two template variables:

  • $datasource - Your Prometheus instance
  • $job - Job name filter (supports multi-select)

Available Metrics

NodeLink exposes metrics through the /v4/metrics endpoint. All metrics follow the Prometheus format.

Players & Playback

MetricTypeDescription
nodelink_playersgaugeTotal number of active players
nodelink_playing_playersgaugeNumber of players currently streaming audio
nodelink_uptime_msgaugeServer uptime in milliseconds
nodelink_playback_events_totalcounterTotal playback events fired

Audio Frame Statistics

MetricTypeDescription
nodelink_frames_sentgaugeTotal audio frames successfully sent to Discord
nodelink_frames_nulledgaugeFrames that were dropped or nulled (indicates potential audio issues)
nodelink_frames_deficitgaugeDifference between expected and actual frames (positive = lag)
nodelink_frames_expectedgaugeTotal number of frames that should have been sent

High frames_nulled or positive frames_deficit indicates audio quality problems.

API & Source Tracking

MetricTypeDescription
nodelink_api_requests_totalcounterTotal API requests (labeled by endpoint)
nodelink_api_errors_totalcounterAPI errors counter
nodelink_source_requests_totalcounterRequests to audio sources (YouTube, Spotify, etc.)

Example endpoints tracked: /v4/loadtracks, /v4/stats, /v4/info, /v4/loadlyrics

System Resources

MetricTypeDescription
nodelink_memory_free_bytesgaugeFree system memory
nodelink_memory_used_bytesgaugeMemory used by NodeLink process
nodelink_memory_allocated_bytesgaugeTotal allocated memory
nodelink_memory_reservable_bytesgaugeAvailable reservable memory
nodelink_cpu_coresgaugeNumber of CPU cores available
nodelink_cpu_system_loadgaugeSystem-wide CPU load average
nodelink_cpu_nodelink_loadgaugeNodeLink process CPU usage (0-1 scale)

Node.js Runtime Metrics

These are automatically collected by prom-client and provide deep insights into the Node.js process.

Event Loop

MetricTypeDescription
nodejs_eventloop_lag_secondsgaugeEvent loop lag
nodejs_eventloop_lag_min_secondsgaugeMinimum recorded lag
nodejs_eventloop_lag_max_secondsgaugeMaximum recorded lag
nodejs_eventloop_lag_mean_secondsgaugeMean lag
nodejs_eventloop_lag_stddev_secondsgaugeStandard deviation
nodejs_eventloop_lag_p50_secondsgauge50th percentile (median)
nodejs_eventloop_lag_p90_secondsgauge90th percentile
nodejs_eventloop_lag_p99_secondsgauge99th percentile

High lag values indicate the event loop is blocked, which can cause audio stuttering.

Memory & Heap

MetricTypeDescription
nodejs_heap_size_total_bytesgaugeTotal heap size
nodejs_heap_size_used_bytesgaugeUsed heap size
nodejs_external_memory_bytesgaugeExternal memory (C++ buffers, audio data)
nodejs_heap_space_size_total_bytesgaugeHeap space size by type (new, old, code, large_object, etc.)
nodejs_heap_space_size_used_bytesgaugeUsed heap space by type
nodejs_heap_space_size_available_bytesgaugeAvailable heap space by type

Heap spaces include: new, old, code, large_object, trusted, and more.

Garbage Collection

MetricTypeDescription
nodejs_gc_duration_secondshistogramGC pause durations by kind (minor, major, incremental, weakcb)

Frequent or long GC pauses can impact audio streaming performance.

Active Resources

MetricTypeDescription
nodejs_active_handlesgaugeActive libuv handles by type (Server, Socket, Pipe, etc.)
nodejs_active_handles_totalgaugeTotal active handles
nodejs_active_requestsgaugeActive libuv requests
nodejs_active_requests_totalgaugeTotal active requests
nodejs_active_resourcesgaugeActive resources by type (Timeout, TCPWrap, etc.)
nodejs_active_resources_totalgaugeTotal active resources

Process Info

MetricTypeDescription
nodejs_version_infogaugeNode.js version information
process_resident_memory_bytesgaugeResident Set Size (physical RAM used)
process_virtual_memory_bytesgaugeVirtual memory size
process_open_fdsgaugeNumber of open file descriptors
process_max_fdsgaugeMaximum file descriptors allowed

Example Queries

Audio Quality

MetricTypeDescription
nodelink_playing_playersGaugeActive players streaming audio
nodelink_frames_sentCounterSuccessfully delivered audio frames
nodelink_frames_expectedCounterFrames expected (3000/min per player)
nodelink_frames_nulledCounterEmpty frames sent
nodelink_frames_deficitGaugeDifference 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: warning

Event 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.

On this page