Skip to content

feat(helm): Add monitoring.scrapeAnnotations to control whether or not to add prometheus.io/* annotations to Service#825

Open
azagarelz wants to merge 1 commit into
Cloudzero:developfrom
azagarelz:feat/monitoring-scrape-annotations-toggle
Open

feat(helm): Add monitoring.scrapeAnnotations to control whether or not to add prometheus.io/* annotations to Service#825
azagarelz wants to merge 1 commit into
Cloudzero:developfrom
azagarelz:feat/monitoring-scrape-annotations-toggle

Conversation

@azagarelz
Copy link
Copy Markdown

Why?

When components.monitoring.enabled is true (or auto with CRDSs installed), the chart creates ServiceMonitor CRDs that instruct the Prometheus Operator on how to scrape CZ metrics. In that configuration, the prometheus.io/* annotations on Services become redundant.
In clusters where both annotation-based discovery and CRD-based discovery are active simultaneously, CZ metrics may be scraped twice, generating unnecessary load.

Setting scrapeAnnotations: false removes the annotations from Services, eliminating the risk of double scraping while keeping the ServiceMonitor based discovery intact. The default remains true for full backward compatibility.

What

  • Adds components.monitoring.scrapeAnnotations value (default: true)
  • When set to false, remove prometheus.io/* annotations from the agent, aggregator, and webhook Services
  • Updates monitoring-infrastructure.md to document the new flag and the double scraping scenario
  • Adds helm unit tests covering both true and false scenarios

How Tested

Helm unit tests added in charts/cloudzero-agent/tests/defaults_service_test.yaml covering:

  • Default behaviour: prometheus.io/scrape annotation present on all three Services
  • Opt-out: annotation absent on all three Services when scrapeAnnotations: false

@azagarelz azagarelz changed the title Add monitoring.scrapeAnnotations to control whether or not to add prometheus.io/* annotations to Service feat(helm): Add monitoring.scrapeAnnotations to control whether or not to add prometheus.io/* annotations to Service May 25, 2026
@azagarelz azagarelz marked this pull request as ready for review May 25, 2026 22:32
@azagarelz azagarelz requested a review from a team as a code owner May 25, 2026 22:32
…nnotations

When monitoring.enabled is true (or auto with CRDs installed), the chart
creates ServiceMonitor CRDs that instruct the Prometheus Operator to scrape
CloudZero Agent metrics. In that configuration, the prometheus.io/* annotations
on Services become redundant. In clusters where both annotation-based and
CRD-based discovery are active simultaneously, metrics may be scraped twice,
generating unnecessary load on the metrics pipeline.

Adds components.monitoring.scrapeAnnotations (default: true) to address this.
When set to false, prometheus.io/* annotations are omitted from the agent,
aggregator, and webhook Services, eliminating the risk of double scraping while
keeping ServiceMonitor-based discovery intact. Updates monitoring-infrastructure.md
to document the new flag and the double scraping scenario, and adds helm unit
tests covering both true and false states for all three affected Services.

The default value of true preserves full backward compatibility for users
relying on annotation-based Prometheus discovery without the Operator. This
approach is purely additive, users without ServiceMonitors are unaffected,
while Operator users gain a clean way to eliminate redundant scrape targets.
A future consideration would be auto-disabling annotations when monitoring.enabled
is true, though that would be a breaking change requiring a major version bump.
@azagarelz azagarelz force-pushed the feat/monitoring-scrape-annotations-toggle branch from f570231 to 20a7bf7 Compare May 25, 2026 22:37
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