Skip to content

feat(helm): add Prometheus operator ServiceMonitor support - #3847

Open
aWN4Y25pa2EK wants to merge 1 commit into
vectorize-io:mainfrom
infernet-org:feat/helm-service-monitor
Open

feat(helm): add Prometheus operator ServiceMonitor support#3847
aWN4Y25pa2EK wants to merge 1 commit into
vectorize-io:mainfrom
infernet-org:feat/helm-service-monitor

Conversation

@aWN4Y25pa2EK

@aWN4Y25pa2EK aWN4Y25pa2EK commented Aug 27, 2026

Copy link
Copy Markdown

Problem

The api (port 8888) and worker (port 8889) containers expose Prometheus format metrics at /metrics, but the chart wires scraping for neither: the worker Service's scrape annotations are gated behind the unrelated podAnnotations value (dead by default), the api Service has no annotations at all, and no ServiceMonitor exists. The dev LGTM stack also only scraped the api — worker metrics were not collected in any shipped configuration.

What changed

  • templates/servicemonitor.yaml (new): per-component ServiceMonitor resources — api whenever api.enabled, worker only when worker.enabled — gated on metrics.serviceMonitor.enabled (default false).
  • values.yaml: metrics.serviceMonitor block (labels for operator selection, path, interval, scrapeTimeout) with operator prerequisites documented.
  • README.md: values table rows + "Prometheus metrics" section.
  • scripts/dev/monitoring/prometheus.yml: add hindsight-worker job (host.docker.internal:8889).

The worker monitor targets the headless Service, so each StatefulSet replica gets its own scrape target (hindsight-worker-0/1). The control plane exposes no metrics (Next.js, no instrumentation) and is intentionally excluded.

Usage

metrics:
  serviceMonitor:
    enabled: true
    labels:
      release: kube-prometheus-stack  # match the stack's serviceMonitorSelector

Validation

  • helm lint clean; renders verified: 0 monitors by default, 1 with api-only, 2 with worker.enabled=true; selector labels stable (name/instance/component); user labels land on monitor metadata.
  • End-to-end on k3d + kube-prometheus-stack: installed chart with worker.enabled=true, metrics.serviceMonitor.enabled=true, metrics.serviceMonitor.labels.release=kps; both monitors created and reconciled; Prometheus active targets:
    • hindsight-api http://10.42.0.17:8888/metrics health=up
    • hindsight-worker http://10.42.0.18:8889/metrics health=up
    • hindsight-worker http://10.42.0.19:8889/metrics health=up
    • up == 1 for all three jobs; api served 113 hindsight_* samples, worker 28 (db pool, process, poller families).

Notes

  • Requires the monitoring.coreos.com/v1 CRDs; without the operator nothing is emitted (default off), so plain installs are unaffected.
  • Unrelated chart findings from a full assessment (missing values.schema.json, broken existingSecret + external-DB path, duplicate env entries under SSA, pgvector:latest pin) are tracked separately and not addressed here.

The api (port 8888) and worker (port 8889) containers expose Prometheus
format metrics at /metrics (verified against app source); the chart had
no wiring for them — the worker's scrape annotations are gated behind
the unrelated podAnnotations value and the api service had nothing.

Add a gated metrics.serviceMonitor block that emits per-component
ServiceMonitor resources (api always when enabled, worker only when
worker.enabled). Selection labels are configurable for the Prometheus
operator's serviceMonitorSelector (e.g. release: kube-prometheus-stack).
Also scrape the dedicated worker in the dev LGTM compose stack, which
previously only scraped the api on :8888.

Verified end-to-end on k3d + kube-prometheus-stack: all three targets
(api + 2 worker pods via headless endpoints) discovered and up=1.
@strix-security

strix-security Bot commented Aug 27, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for 64dee42.


Reviewed by Strix
Re-run review · Configure security review settings

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