How to monitor Celery

Monitor Celery by checking that the expected number of workers answer celery inspect ping, that queue length in the broker stays below a limit, that periodic tasks from celery beat actually complete (a heartbeat per important task), and that task exceptions reach an error tracker. Vigil covers each with agent commands, heartbeats and a Sentry-compatible endpoint.

Updated · by PuzariCloud · commands checked against current releases

What can go wrong with Celery

  • Workers alive but stuck. A task blocks on a network call with no timeout and the worker's slots stay busy. Processes look fine; the queue grows.
  • Queue backlog. Producers outpace workers after a traffic spike or a slow dependency. Users wait minutes for emails, exports or payments to process.
  • celery beat not running, or running twice. No beat means no periodic tasks at all, with no error. Two beats means every periodic task runs twice.
  • Errors swallowed. A task that raises is logged on the worker and retried or dropped; unless something collects the exception, nobody sees it.
  • Redis visibility timeout. With the Redis broker, a task not acknowledged within visibility_timeout (1 hour by default) is delivered again, so long tasks with acks_late can run twice.

The signals that matter, with alert thresholds

SignalAlert whenWhy it matters
Workers answering pingfewer than you runCapacity lost.
Queue length per queue> a few minutes' worth of workBacklog building.
Periodic task success pinglatebeat or the task is broken.
Task exceptionsnew error type, or a spikeBugs and failing dependencies.
Worker memorygrowing without boundLeak; set --max-tasks-per-child.

Thresholds are starting points. Tune them after a week of data: an alert nobody acts on should be raised or removed.

How to check Celery by hand

Which workers answer, and what are they running?
celery -A proj inspect ping
celery -A proj inspect active
Tasks reserved (prefetched) but not started
celery -A proj inspect reserved
Queue length with the Redis broker (queue 'celery', db 0)
redis-cli -n 0 llen celery
Queue length with RabbitMQ
sudo rabbitmqctl list_queues name messages consumers
Is beat running?
systemctl status celerybeat     # or: pgrep -af 'celery.*beat'

How to watch Celery with Vigil

  1. Add the host under Servers and run the one-line installer it shows (curl -fsSL https://puzaricloud.in/install-server-agent.sh | sh -s -- --token <token>). The agent is one Python file with no dependencies; CPU, memory, disk, inode and load rules start working with the first report. Add the worker service and beat to the systemd services to watch.
  2. Add the commands below: missing workers (limit celery_workers_missing = 1) and queue length (limit e.g. celery_queue = 500). Commands run every interval with a 10-second timeout.
  3. For each periodic task that matters, create a Heartbeat in New monitor with the beat schedule, and call the ping URL (e.g. with httpx) at the end of the task. If beat stops, the pings stop.
  4. Create a project under Errors and use its DSN with sentry_sdk.init(dsn=…); the Sentry SDK enables its Celery integration automatically, so task exceptions arrive grouped with arguments and breadcrumbs.
  5. For task traces, use opentelemetry-instrumentation-celery and send spans to the OTLP endpoint (quick start).
/etc/vigil-agent.json (4 workers expected, Redis broker)
{
  "commands": {
    "celery_workers_missing": "cd /srv/app && echo $(( 4 - $(.venv/bin/celery -A proj inspect ping 2>/dev/null | grep -c pong) ))",
    "celery_queue": "redis-cli -n 0 llen celery"
  }
}

Every alert goes to the channels you pick: email, Slack, Telegram, Discord, Microsoft Teams, Pushover, webhooks or on-call paging. Failures are confirmed by a second check before anyone is woken up.

Celery monitoring FAQ

Why not use Flower?

Flower is good for looking at workers and tasks interactively. It does not page anyone when a worker vanishes or a queue grows, which is what the commands and heartbeats here are for. Use both if you like Flower's UI.

What queue length should alert?

Think in time: queue length divided by throughput. If workers finish 50 tasks a minute and users should wait at most 5 minutes, alert at 250.

How do I stop memory leaks in workers?

Set --max-tasks-per-child (or worker_max_tasks_per_child) so each process is replaced after N tasks, and watch memory on the server to confirm it levels off.

Vigil by PuzariCloud

Watch Celery without stitching five tools together

Uptime and API checks, heartbeats, server and database metrics, traces, errors and logs in one place, with one incident and one alert when something breaks. Every feature is on every plan, including Free.