Monitoring FFmpeg transcoding workers with Netdata

Hi everyone, I run a few servers that transcode user-uploaded videos with FFmpeg, driven by a PHP queue. I’d like Netdata to alert me when a worker is stuck (100% CPU for a long time but no output growth) or when the queue backs up. Is the apps.plugin per-process view the right way to track FFmpeg processes, or would you write a custom collector reading the queue length from Redis? Any example alert configs would be really helpful. Thanks!

Hi!

Use both. apps.plugin is the right tool for the FFmpeg workers; the queue length has to be pushed in by them, because the Redis collector reads server stats (INFO) only and cannot report the length of a specific list/stream key.

The steps are:

1. FFmpeg workers (apps.plugin)

Add a custom application group:

cd /etc/netdata
sudo ./edit-config apps_groups.conf

Add one line:
ffmpeg_workers: *ffmpeg*

Then restart the agent:
sudo systemctl restart netdata

You’ll get a dedicated ffmpeg_workers set of charts (CPU, memory, disk I/O, process count) under Applications > Application Groups.

To find which worker is stuck, open the node’s Live view > Processes and filter on the ffmpeg_workers category (you get per-PID CPU, write rate and uptime there).

2. Stuck-worker alert (busy CPU, no output being written)

cd /etc/netdata
sudo touch health.d/ffmpeg.conf
sudo ./edit-config health.d/ffmpeg.conf

template: ffmpeg_workers_cpu_15m
     on: app.cpu_utilization
chart labels: app_group=ffmpeg_workers
   lookup: average -15m unaligned of user,system
    units: percentage
    every: 1m
      to: silent

template: ffmpeg_workers_stalled
     on: app.disk_logical_io
chart labels: app_group=ffmpeg_workers
   lookup: average -15m unaligned absolute of writes
    units: KiB/s
    every: 1m
    crit: $this < 16 and $ffmpeg_workers_cpu_15m > 100
   delay: up 5m down 15m multiplier 1.5 max 1h
  summary: ffmpeg worker spinning without producing output
      to: sysadmin

Apply with sudo netdatacli reload-health.

CPU here is 100% = 1 core, so > 100 means at least one worker fully busy (raise it if you run several workers per machine). Tune 16 KiB/s down/up to what “no output” means for your encodes.

3. Queue depth (push it yourself)

The Redis collector reports server-level stats only, not the length of a given key, so the lowest-effort route is StatsD (built into the agent, UDP 8125, on by default). Have your PHP worker send the number after each LLEN:

echo "transcode.queue_length:42|g" | nc -u -w1 127.0.0.1 8125

That creates a statsd_transcode.queue_length_gauge chart. Alert on it in the same health file:

template: transcode_queue_backlog
     on: statsd_transcode.queue_length_gauge
   lookup: average -5m unaligned of gauge
    units: jobs
    every: 30s
     warn: $this > 100
     crit: $this > 500
   delay: up 5m down 15m multiplier 1.5 max 1h
  summary: Transcode queue is backing up
      to: sysadmin


Again sudo netdatacli reload-health.

If you’d rather not touch PHP, a small script via the Nagios/scripts.d collector or a Prometheus endpoint scraped by the go.d Prometheus collector both work just as well.

Docs worth a look:
• Applications collector — learn.netdata.cloud
• Processes live view — learn.netdata.cloud
• Alert reference — learn.netdata.cloud
• StatsD — learn.netdata.cloud
• Redis collector — learn.netdata.cloud