Repository navigation
telemetry: add bounded self-metrics, /metrics endpoint, and ServiceMonitor - #23101
Conversation
…nitor Adds a pkg/api/metrics package exposing console_http_requests_total and console_http_request_duration_seconds via the console's existing prometheus/client_golang dependency, mounted at GET /metrics alongside the existing /healthz probe. Labels are bounded to the registered Fiber route pattern (never the raw request path), method, and status code, so cardinality stays fixed regardless of request input. Adds an opt-in (disabled by default) ServiceMonitor Helm template and values.yaml knob for clusters that already run Prometheus Operator. No exporter or external data flow is introduced — metrics are only pulled by an operator-controlled Prometheus scraping this pod. Fixes #23055 Signed-off-by: kubestellar-hive[bot] <223556219+Copilot@users.noreply.github.com>
|
Important Held for human sign-off on the direction, not on the code. This PR's only tracked rationale is #23055, which the hive filed itself — issue #23055 was filed by kubestellar-hive[bot] and no human has acknowledged it. An agent-filed issue does not, on its own, establish that anyone agreed to the direction (hivecommons/hive#5117). The change may well be right; nothing here is a review of it. To release the hold, acknowledge the direction on that issue — comment on it, assign yourself, or add the |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!
This is an automated message. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
✅ Post-Merge Verification: passedCommit: |
Summary
Closes #23055 — the console backend already carries
prometheus/client_golangas a direct dependency (used inpkg/gpu/scraper.goto scrape external clusters) but never exposed its own metrics.Changes
pkg/api/metricspackage registering two bounded-label Prometheus collectors:console_http_requests_total{method, route, status}console_http_request_duration_seconds{method, route}routeis always the registered Fiber route pattern (e.g./api/clusters/:name), never the raw request path, so cardinality stays fixed regardless of request input (unmatched/404 requests are bucketed under a singleunmatchedlabel).GET /metricsinpkg/api/routes_health.goalongside the existing/healthz//healthprobes, and wired the recording middleware inpkg/api/middleware_setup.go.ServiceMonitorHelm template (deploy/helm/kubestellar-console/templates/servicemonitor.yaml) plus ametrics.serviceMonitorvalues.yaml knob, for operators who already run Prometheus Operator.pkg/api/metrics/metrics_test.go) asserting the recorded label is the bounded route pattern and that raw path values never leak into metric labels.Why this is safe
/metrics. Nothing is pushed off-box, and no exporter/collector config is added.Testing
go build ./pkg/api/...go test ./pkg/api/...(full package, including the newpkg/api/metricstest) — all passgofmt -lclean on all new/modified files— hive: agent=telemetry backend=copilot model=claude-sonnet-4-6