Skip to main content

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="..."}, counter
  • celery_task_queuetime_seconds{queue}, histogram (only if task_send_sent_event is 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).

Changelog

2.0.1 (2026-10-29)

Maintenance

  • deps: update actions/setup-python digest to 6d4fd22 (#12) (975f9f4)
  • enable Renovate with the shared eng presets (b94e319)
  • enable Renovate with the shared eng presets (fce3373)
  • release with Release Please via the shared pypi-release workflow (b8423b5)
  • release with Release Please via the shared pypi-release workflow (8ff0ade)

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_timeout in broker_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_length is left out instead of keeping stale values; see the README on how to alert on that
  • Replace --queuelength-interval=x with 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 setuptools dependency

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 queue label to task_queuetime and task_runtime metrics

1.3.0 (2022-09-14)

  • Add queue label to celery_tasks_total metric
  • Add separate state retries-exceeded (previously used failed)

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

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for celery_redis_prometheus 2.0.1
File Size Uploaded Provenance Actions
celery_redis_prometheus-2.0.1.tar.gz 37.2 kB Without provenance Details for celery_redis_prometheus-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for celery_redis_prometheus 2.0.1
File Interpreter ABI Platform Actions
celery_redis_prometheus-2.0.1-py3-none-any.whl Python 3 none any Details for celery_redis_prometheus-2.0.1-py3-none-any.whl

Total release size: 47.4 kB

Release files / celery_redis_prometheus-2.0.1.tar.gz

Download URL celery_redis_prometheus-2.0.1.tar.gz
Size 37.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ff90ac14bb6ea9aa18c449a1ea9005137c8ff07bf06999a9a2015cb4a85f52e2
BLAKE2b-256 checksum
How to use checksums
4821bd582883893cb0dee00776e2adfe63422ebeded39acfa95cf9eb726f24d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.1-py3-none-any.whl

Download URL celery_redis_prometheus-2.0.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb868c96066026eae3c683bea8727a50f5c04f3bafb757cda74fc4f051332832
BLAKE2b-256 checksum
How to use checksums
85745de8be1c2d9e1450156031da006b09438016c60418f6b50bf2827f3b69ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}

Security for celery_redis_prometheus 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page