Skip to content

Expose a Prometheus /metrics endpoint (#3) - #172

Open
donkk11 wants to merge 1 commit into
kaaval:mainfrom
donkk11:feat/prometheus-metrics-endpoint
Open

donkk11 wants to merge 1 commit into
kaaval:mainfrom
donkk11:feat/prometheus-metrics-endpoint

Conversation

@donkk11

@donkk11 donkk11 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #3.

Adds /metrics — real gauges computed on every scrape (a live query, not a
cached counter), covering scans, vulnerabilities, asset-vulnerabilities,
integration findings, RBAC scan results, and endpoints, each broken down by
their real status/severity labels.

No sensitive data in metric labels — checked: only status/severity strings,
never asset IDs, CVE IDs, hostnames, or tenant IDs.

One open question for the maintainer: /metrics is currently unauthenticated,
matching standard Prometheus practice (scrape-only, restricted by network
policy rather than app-level auth). Flagging it explicitly rather than
deciding it silently — happy to add auth if you'd rather it be gated.

Tests: 5 new tests in tests/test_metrics.py, covering the collector directly
and the real HTTP route end-to-end (status code, content-type, dependency
injection). Full non-DB suite: 152/152 passing.

Closes kaaval#3.

Adds /metrics — real gauges computed on every scrape (a live query, not a
cached counter), covering scans, vulnerabilities, asset-vulnerabilities,
integration findings, RBAC scan results, and endpoints, each broken down by
their real status/severity labels.

No sensitive data in metric labels — checked: only status/severity strings,
never asset IDs, CVE IDs, hostnames, or tenant IDs.

One open question for the maintainer: /metrics is currently unauthenticated,
matching standard Prometheus practice (scrape-only, restricted by network
policy rather than app-level auth). Flagging it explicitly rather than
deciding it silently — happy to add auth if you'd rather it be gated.

Tests: 5 new tests in tests/test_metrics.py, covering the collector directly
and the real HTTP route end-to-end (status code, content-type, dependency
injection). Full non-DB suite: 152/152 passing.

Signed-off-by: KK Nkama <[email protected]>

@rrskris rrskris left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isolated registry per scrape and the HTTP-level test are useful foundations. The current collector does not yet satisfy #3's requirement to expose the latest persisted CVE and RBAC findings.

The active CVE paths write CVEScanResult and K8sCVEScanResult, while kaaval_scans_total and kaaval_vulnerabilities_total query the legacy Scan and Vulnerability tables. Counting RBACScanResult rows by status also counts historical scans rather than current findings.

Please derive the finding counts by severity, maximum contextual score, and last-scan timestamp from the latest scan results, then add the PrometheusRule example requested by #3. Include a regression that seeds two scans with different findings and proves only the latest contributes. Define the multi-cluster aggregation explicitly so one cluster's new scan does not hide another cluster's results. Keep this change within the current CVE/RBAC scope; image imports can be a follow-up.

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.

Expose a Prometheus /metrics endpoint

2 participants