celery_redis_prometheus
Exports task execution metrics in Prometheus format: how many tasks were started and have completed successfully or with failure, and how many tasks are still in the queues (supported only for broker redis).
Inspired by https://gitlab.com/kalibrr/celery-prometheus
Usage
Start HTTP service
Start the HTTP server like this:
$ bin/celery prometheus --host=127.0.0.1 --port=9691
Configure Prometheus
scrape_configs:
- job_name: 'celery'
static_configs:
- targets: ['localhost:9691']
We export the following metrics:
celery_tasks_total{state="started|succeeded|failed|retried|retries-exceeded", queue="..."}, countercelery_task_queuetime_seconds{queue}, histogram (only iftask_send_sent_eventis enabled in Celery)celery_task_runtime_seconds{queue}, histogram
If you pass --queue-length, the queue lengths are read from the broker on each scrape (NOTE: this only works with redis as the broker), resulting in this additional metric:
celery_queue_length{queue="..."}, gauge
While the broker cannot be reached, celery_queue_length is left out.
So an alert like celery_queue_length > 100 silently stops firing;
add one that fires when the metric is missing.
With a single exporter per alert selector, absent() does that:
- alert: CeleryQueueLengthMissing
expr: absent(celery_queue_length{namespace="myapp"})
for: 5m
absent() only fires if no series matches the selector at all.
If the selector covers several exporters (e.g. one per broker),
one of them failing goes unnoticed as long as another still reports.
Compare against the up series Prometheus records for each scrape target instead,
which yields one alert per exporter that is down or cannot read its broker:
- alert: CeleryQueueLengthMissing
expr: up{job="myapp/celery-metrics"} unless on(namespace, pod) celery_queue_length
for: 5m
The up selector must match only exporters started with --queue-length, and on(...)
must name labels that identify the exporter on both sides.
Run tests
With bin/test wrapper script (or uv run pytest).
celery_redis_prometheus changes
2.0.0 (2026-10-12)
- Give up reading queue lengths on a hanging broker after 3 seconds per connect, handshake and query (so about 9 seconds at worst), to still answer within the default 10 second scrape timeout. Configurable via
socket_timeout/socket_connect_timeoutinbroker_transport_options - Read queue lengths from the broker on each scrape instead of polling them in a background thread. While the broker cannot be reached,
celery_queue_lengthis left out instead of keeping stale values; see the README on how to alert on that - Replace
--queuelength-interval=xwith the flag--queue-length. The old option is rejected, so update the exporter arguments when upgrading
2.0.0 (unreleased)
- Nothing changed yet.
1.5.2 (2026-07-27)
- Remove unused
setuptoolsdependency
1.5.1 (2023-10-27)
- Fix brown-bag release
1.5.0 (2023-10-27)
- Be explicit about unregistering default collectors
1.4.0 (2022-10-28)
- Add
queuelabel to task_queuetime and task_runtime metrics
1.3.0 (2022-09-14)
- Add
queuelabel tocelery_tasks_totalmetric - Add separate state
retries-exceeded(previously usedfailed)
1.2.0 (2022-06-23)
- Update to celery-5.x
1.1.1 (2020-03-20)
- Fix py2 class syntax issues
1.1.0 (2020-03-20)
- Make py2 compatible.
1.0.0 (2020-03-20)
- Initial release
Metadata
Release files for celery_redis_prometheus 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| celery_redis_prometheus-2.0.0.tar.gz | 60.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| celery_redis_prometheus-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 70.3 kB
Release files / celery_redis_prometheus-2.0.0.tar.gz
| Download URL | celery_redis_prometheus-2.0.0.tar.gz |
|---|---|
| Size | 60.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
009ab4e429da5b0fdf019555e1e2966891ff849e622f4c4690c72591feab0694
|
|
BLAKE2b-256 checksum How to use checksums |
b9b550b0216aff8443bf0c9139c0408f6a3102fc239bb1ebaca2826c2e93035d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / celery_redis_prometheus-2.0.0-py3-none-any.whl
| Download URL | celery_redis_prometheus-2.0.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aead25f622a01882707a0afd0733ec55d48459ac38bf2f7d15ffd92c9fd75afb
|
|
BLAKE2b-256 checksum How to use checksums |
04949a2aaf3f7d1fdd6f7d9db621ad2e0213d9f93c56b36e84781b967c66ce74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|