Skip to content

telemetry: add bounded self-metrics, /metrics endpoint, and ServiceMonitor - #23101

Merged
clubanderson merged 1 commit into
mainfrom
telemetry/console-metrics-endpoint-23055
Sep 3, 2026
Merged

clubanderson merged 1 commit into
mainfrom
telemetry/console-metrics-endpoint-23055

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Summary

Closes #23055 — the console backend already carries prometheus/client_golang as a direct dependency (used in pkg/gpu/scraper.go to scrape external clusters) but never exposed its own metrics.

Changes

  • New pkg/api/metrics package registering two bounded-label Prometheus collectors:
    • console_http_requests_total{method, route, status}
    • console_http_request_duration_seconds{method, route}
    • route is 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 single unmatched label).
  • Mounted GET /metrics in pkg/api/routes_health.go alongside the existing /healthz//health probes, and wired the recording middleware in pkg/api/middleware_setup.go.
  • Added an opt-in, disabled-by-default ServiceMonitor Helm template (deploy/helm/kubestellar-console/templates/servicemonitor.yaml) plus a metrics.serviceMonitor values.yaml knob, for operators who already run Prometheus Operator.
  • Unit test (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

  • No external data flow: metrics are only ever pulled by an operator-controlled Prometheus scraping this pod's /metrics. Nothing is pushed off-box, and no exporter/collector config is added.
  • No backend is confirmed for this project per current audit policy, so this PR is scoped to self-metrics + opt-in scrape config only — no dashboards or alert rules are included.
  • Labels are bounded (method, registered route, status) — verified by the added test.

Testing

  • go build ./pkg/api/...
  • go test ./pkg/api/... (full package, including the new pkg/api/metrics test) — all pass
  • gofmt -l clean on all new/modified files

— hive: agent=telemetry backend=copilot model=claude-sonnet-4-6

…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>
@hivecommons-hive hivecommons-hive Bot added the hold Blocked — do not touch label Sep 3, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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 approved-direction label — and remove the hold label here.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 3, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign eeshaansa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit e1a88ad
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a998ee353c0da000844f540

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions github-actions Bot added ai-generated Pull request generated by AI tier/2-standard labels Sep 3, 2026
@clubanderson
clubanderson merged commit 53bb7e0 into main Sep 3, 2026
43 of 44 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the telemetry/console-metrics-endpoint-23055 branch September 3, 2026 16:30
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Post-merge build verification passed ✅

Both Go and frontend builds compiled successfully against merge commit 53bb7e0b2b3d913ed96416103a27c76be04894e3.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 53bb7e0b2b3d913ed96416103a27c76be04894e3
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/33779080031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. hold Blocked — do not touch size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[telemetry] Console backend exposes no /metrics endpoint despite having prometheus/client_golang

2 participants