feat(helm): add Prometheus operator ServiceMonitor support - #3847
Open
aWN4Y25pa2EK wants to merge 1 commit into
Open
feat(helm): add Prometheus operator ServiceMonitor support#3847aWN4Y25pa2EK wants to merge 1 commit into
aWN4Y25pa2EK wants to merge 1 commit into
Conversation
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 ReviewNo security issues found. Updated for Reviewed by Strix |
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.
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 unrelatedpodAnnotationsvalue (dead by default), the api Service has no annotations at all, and noServiceMonitorexists. 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-componentServiceMonitorresources — api wheneverapi.enabled, worker only whenworker.enabled— gated onmetrics.serviceMonitor.enabled(defaultfalse).values.yaml:metrics.serviceMonitorblock (labelsfor operator selection,path,interval,scrapeTimeout) with operator prerequisites documented.README.md: values table rows + "Prometheus metrics" section.scripts/dev/monitoring/prometheus.yml: addhindsight-workerjob (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
Validation
helm lintclean; renders verified: 0 monitors by default, 1 with api-only, 2 withworker.enabled=true; selector labels stable (name/instance/component); user labels land on monitor metadata.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=uphindsight-worker http://10.42.0.18:8889/metrics health=uphindsight-worker http://10.42.0.19:8889/metrics health=upup == 1for all three jobs; api served 113hindsight_*samples, worker 28 (db pool, process, poller families).Notes
monitoring.coreos.com/v1CRDs; without the operator nothing is emitted (default off), so plain installs are unaffected.values.schema.json, brokenexistingSecret+ external-DB path, duplicate env entries under SSA,pgvector:latestpin) are tracked separately and not addressed here.