Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prometheus Metrics Exporter for Celery #42

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Add Prometheus Metrics Exporter for Celery #42

merged 2 commits into from
Dec 5, 2024

Conversation

berggren
Copy link
Contributor

@berggren berggren commented Nov 28, 2024

Summary:

This PR integrates a Prometheus metrics exporter to collect and expose performance data related to Celery tasks.

Technical Details:

  • New Metrics Exporter: A new Prometheus exporter has been implemented in src/metrics/exporter.py. This exporter leverages the prometheus_client library to collect various metrics related to Celery tasks, such as task sent, received, started, succeeded, failed, rejected, revoked, and retried counts, as well as task runtime. The exporter exposes these metrics on port 8080, allowing Prometheus to scrape them.
  • Metrics Implementation: The exporter uses counters and histograms to track task events and runtime. It extracts relevant information from Celery events, such as task name, hostname, and runtime, to provide detailed metrics. Labels are used effectively to categorize metrics by task name and hostname, enabling granular monitoring. Error handling for failed tasks is planned but not yet implemented.
  • Celery Integration: The exporter.py script establishes a connection to the Celery broker and listens for task and worker events. It processes these events to update the Prometheus metrics accordingly.
  • Dockerfile for Metrics Exporter: A new Dockerfile has been created in src/metrics/Dockerfile to build and run the metrics exporter as a standalone container. This allows for independent deployment and scaling of the metrics exporter.
  • API Endpoint and Routing: A new API endpoint /metrics has been added and routed to the metrics exporter. This endpoint serves the Prometheus metrics, allowing them to be scraped by Prometheus.
  • Dependency Management: The prometheus-client package has been added as a dependency in pyproject.toml and poetry.lock files.

@berggren berggren merged commit 36b1dc6 into main Dec 5, 2024
1 check passed
@berggren berggren deleted the metrics branch December 5, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant