CP-42614: Add monitoring discovery model (enabled + discovery.method)#840
Open
evan-cz wants to merge 1 commit into
Open
CP-42614: Add monitoring discovery model (enabled + discovery.method)#840evan-cz wants to merge 1 commit into
evan-cz wants to merge 1 commit into
Conversation
9a9eecf to
e4ce503
Compare
The chart's monitoring integration could advertise the agent's metrics two ways at once -- prometheus.io/* annotations and ServiceMonitor CRDs -- which scrape the same targets twice. This finalizes the still-in-validation monitoring configuration into an explicit, opt-in model. Implementation Approach: The chart emits two kinds of monitoring resources -- Prometheus Operator CRDs (ServiceMonitor + PrometheusRule) and prometheus.io/* annotations on the agent Services. Both are driven by two values resolved in helm/templates/_helpers.tpl and consumed by the Service, ServiceMonitor, and PrometheusRule templates. There is no cluster auto-detection; the configuration is explicit. This finalizes the still-in-validation monitoring integration added in CP-34935, so its defaults change: the default install emits nothing, and enabled:true selects one mechanism via discovery.method rather than emitting annotations and ServiceMonitors together. Functional Requirements: 1. Monitoring must be off by default and turned on explicitly. Added components.monitoring.enabled as a plain boolean defaulting to false. The four servicemonitor-*.yaml templates, prometheusrule.yaml, and the prometheus.io/* annotations on the three Service templates are all gated on it via helpers in _helpers.tpl. 2. When enabled, the operator must be able to choose the discovery mechanism. Added components.monitoring.discovery.method (auto | serviceMonitors | annotations, default auto). auto resolves to serviceMonitors today and is left as an enum so a future mechanism can extend it; annotations is an explicit opt-in. serviceMonitors emits monitoring.coreos.com/v1 CRDs, so the install fails if the Prometheus Operator is absent; annotations needs no CRDs. 3. The ServiceMonitors and the PrometheusRule must form a single bundle; annotation-based discovery is discovery-only. serviceMonitorsActive and rulesActive resolve together on the serviceMonitors path, so method=annotations yields no ServiceMonitors and no alert rules. 4. The new values must validate and be documented for users. Updated helm/values.schema.yaml (enabled: boolean; discovery.method enum) and regenerated helm/values.schema.json; set defaults and comments in helm/values.yaml; rewrote helm/docs/monitoring-infrastructure.md as user-facing reference. Validation: - helm lint passing - helm unit tests passing; helm/tests/monitoring_integration_test.yaml and defaults_service_test.yaml were rewritten for the new model - helm schema tests passing, including new fixtures under tests/helm/schema for the default, serviceMonitors, annotations, none, and invalid-value cases. kubeconform validates the rendered ServiceMonitor and PrometheusRule against the CRD catalog - golden manifests regenerated; a default `helm template` emits no ServiceMonitors, no PrometheusRule, and no prometheus.io/* annotations - helm subchart tests passing Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e4ce503 to
492be6e
Compare
dmepham
approved these changes
Jun 11, 2026
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.
Summary
Finalizes the chart's monitoring integration into one explicit, opt-in model. The chart could advertise the agent's metrics two ways at once —
prometheus.io/*annotations andServiceMonitorCRDs — which scrape the same targets twice. Nowcomponents.monitoring.enabledturns monitoring on, andcomponents.monitoring.discovery.methodselects a single discovery mechanism.What changed
components.monitoring.enabled— plain boolean, defaultfalse. Monitoring is off until you turn it on. No cluster auto-detection.components.monitoring.discovery.method(auto|serviceMonitors|annotations, defaultauto) — when enabled, the discovery mechanism:autoresolves toserviceMonitorstoday (left as an enum so a future mechanism can extend it).serviceMonitors→ServiceMonitorresources + thePrometheusRulealert bundle. These aremonitoring.coreos.com/v1CRDs, so the install fails if the Prometheus Operator is absent.annotations→prometheus.io/*annotations only; no Operator CRDs, no alert rules.annotationsis discovery-only. For both at once, add the annotations viadefaults.annotations.values.schema.yaml/.json,values.yaml, andhelm/docs/monitoring-infrastructure.mdupdated; the doc was rewritten as user-facing reference.Configuration changes
This finalizes the still-in-validation monitoring integration (CP-34935), so its defaults change:
prometheus.io/*annotations were emitted unconditionally).enabled: truenow selects a single mechanism viadiscovery.method(defaultserviceMonitors), rather than emitting annotations and ServiceMonitors together.To get annotation-based discovery:
monitoring.enabled: true+monitoring.discovery.method: annotations.Testing
helm lintpassinghelm templateemits no ServiceMonitors, no PrometheusRule, and noprometheus.io/*annotations