Closes #1452 - Implemented Prometheus metrics and ServiceMonitor support for mongodb - #1521
Conversation
…ort for mongodb
|
Good work and thank you for the support! I will do the review and local tests. What I'm also not sure about is the monitoring of arbiter or hidden secondary instances. |
|
Thanks @groundhog2k! Both questions are good ones — and the second one actually surfaced a bug, which I've just pushed a fix for ( 1. Sidecar vs.
|
|
@somaz94 Thank you very much for your help! |
|
Pushed in
One small design note: the hidden metrics Service inherits Validated locally — |
|
Thank you! I will take time for a review and test. |
|
I deployed a local kube-prometheus-stack setup and also a Mongodb with metrics support and at the moment I see alerts because of missing metrics. I will continue verifing this tomorrow. |
|
Thanks for testing it locally — the missing-metrics alerts you saw are a real bug in this PR, and I think I've found the cause. It wasn't the Service/ServiceMonitor wiring; it was that the exporter wasn't collecting anything.
Measured against a live replica set with exporter 0.51.0:
One thing worth knowing when you re-test: the exporter needs a warm-up scrape. The very first request to Could you re-run your kube-prometheus-stack setup against this commit and confirm the alerts clear? If anything is still missing after this, it's likely a separate issue and I'd like to see which metric names your alerts reference. |
|
Thank you!! |
Description
Adds Prometheus metrics support to the mongodb chart, mirroring the pattern already used by the redis / valkey charts. When
metrics.enabled=truethe chart deploys apercona/mongodb_exportersidecar in the StatefulSet, an optional metricsService, and a Prometheus OperatorServiceMonitor.The exporter's
MONGODB_URIis wired automatically:metrics.exporter.uri+ root credentials set (settings.rootUsername/settings.rootPassword) authenticates via the chart's root-credential secret (mongodb://$(MONGO_INITDB_ROOT_USERNAME):$(MONGO_INITDB_ROOT_PASSWORD)@localhost:27017/admin?authSource=admin)uri+ no credentials connects without auth (mongodb://localhost:27017)metrics.exporter.uriset is used verbatim (custom monitoring user / extra options)Known scope: the auto-auth path covers
settings.root*. When root credentials come from an existingSecret (extraEnvSecrets) instead, setmetrics.exporter.uri(or useenv/extraExporterEnvSecrets) to point the exporter at them.Everything is gated behind
metrics.enabled: falseby default, so existing installs are unaffected.What type of PR is this? (check all applicable)
Related Tickets & Documents
Closes #1452
Added tests?
Validation performed locally:
helm lint charts/mongodbpassesct lint --config .github/verify-config.yaml --charts charts/mongodbpasses (yamale schema + yamllint + helm lint)helm templaterendered for 4 scenarios (metrics disabled, enabled without auth, enabled with root credentials, enabled with a custom uri); all produce valid YAML with the expected exporter URI, metrics Service, and ServiceMonitorAdded to documentation?
Also bumped the chart version 0.7.11 to 0.8.0 and added a RELEASENOTES.md entry.
Checklist