Centralize metrics in dedicated module#196
Open
Lore09 wants to merge 6 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.yamland 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
metricssection toconfig.yamland correspondingmetrics_enabledconfiguration inConfig, allowing Prometheus metrics to be enabled or disabled via configuration. [1] [2] [3] [4]Introduced a new
src/metrics.pymodule that defines all Prometheus metric gauges and provides refresh helpers for updating metric values from background tasks.Metrics endpoint and routing:
/metricsendpoint under the dashboard secret path, serving Prometheus-formatted metrics only when enabled in the config; otherwise, returns a 404. [1] [2]Background task integration:
analyze_ips.pyanddashboard_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:
app.py, centralizing metrics routing in the dashboard router for better configurability and separation of concerns. [1] [2]