Skip to content

Centralize metrics in dedicated module#196

Open
Lore09 wants to merge 6 commits into
5-add-prometheus-exporter-for-metricsfrom
5-prometheus-exporter-metrics-module
Open

Centralize metrics in dedicated module#196
Lore09 wants to merge 6 commits into
5-add-prometheus-exporter-for-metricsfrom
5-prometheus-exporter-metrics-module

Conversation

@Lore09
Copy link
Copy Markdown
Collaborator

@Lore09 Lore09 commented May 15, 2026

This pull request introduces Prometheus metrics support to the project, enabling the collection and exposure of key operational and security metrics at a configurable endpoint. The implementation is configurable via config.yaml and can be toggled on or off. The changes also refactor metric-related code into a dedicated module and update background tasks to refresh metrics as part of their normal execution.

Prometheus metrics integration:

  • Added a new metrics section to config.yaml and corresponding metrics_enabled configuration in Config, allowing Prometheus metrics to be enabled or disabled via configuration. [1] [2] [3] [4]

  • Introduced a new src/metrics.py module that defines all Prometheus metric gauges and provides refresh helpers for updating metric values from background tasks.

Metrics endpoint and routing:

  • Exposed a /metrics endpoint under the dashboard secret path, serving Prometheus-formatted metrics only when enabled in the config; otherwise, returns a 404. [1] [2]

Background task integration:

  • Refactored background tasks (analyze_ips.py and dashboard_warmup.py) to use the new metrics refresh helpers, removing direct Prometheus usage from these files and ensuring metrics are updated as part of existing workflows. [1] [2] [3] [4] [5] [6]

Code cleanup:

  • Removed the previous direct mounting of the Prometheus ASGI app from app.py, centralizing metrics routing in the dashboard router for better configurability and separation of concerns. [1] [2]

@Lore09 Lore09 requested a review from carnivuth May 15, 2026 17:50
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