Repository navigation
[amazon-cloudwatch-observability] refactor: single-switch SM/PM scraping under otelContainerInsights.prometheusScrape - #332
Conversation
| - "--auto-instrumentation-nodejs-image={{ template "auto-instrumentation-nodejs.image" . }}" | ||
| - "--target-allocator-image={{ template "target-allocator.image" (merge .Values.agent.prometheus.targetAllocator.image (dict "region" $.Values.region)) }}" | ||
| - "--feature-gates=operator.autoinstrumentation.multiinstrumentation,operator.autoinstrumentation.multiinstrumentation.skipcontainervalidation" | ||
| - "--feature-gates=operator.autoinstrumentation.multi-instrumentation,operator.autoinstrumentation.multi-instrumentation.skip-container-validation" |
| ## Allocator's prometheusCR discovery. When otelContainerInsights.enabled is true, | ||
| ## enabling this gives SM/PM scraping end-to-end (CRDs + Target Allocator + | ||
| ## prometheusCR + RBAC). Only takes effect when otelContainerInsights.enabled is true. | ||
| prometheusScrape: |
There was a problem hiding this comment.
The prometheusScrape bundle moves prometheusCRDs.install and the monitor flags to new prometheusScrape.* keys with no alias, so an existing --set prometheusCRDs.install=never is silently ignored. If we can't guarantee merge order, could we add aliases or a deprecation path?
| - nonResourceURLs: ["/metrics"] | ||
| verbs: ["get"] | ||
| {{- if and (hasKey ($customAgent.prometheus.targetAllocator) "prometheusCR") $customAgent.prometheus.targetAllocator.prometheusCR.enabled }} | ||
| {{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "prometheusCR") $customAgent.prometheus.targetAllocator.prometheusCR.enabled) $otelCIScrape }} |
| @@ -0,0 +1,1429 @@ | |||
| {{- /* | |||
| PodMonitor CRD (monitoring.coreos.com/v1), pinned to prometheus-operator v0.91.0 to | |||
There was a problem hiding this comment.
Header pins these CRDs to prometheus operator v0.91.0 but go.mod is on v0.92.0, so the API server prunes any field added between the two from a user's monitor. Could we refetch both from v0.92.0 (or fix the header)? Same in servicemonitor-crd.yaml.
| @@ -6405,9 +6405,10 @@ spec: | |||
| allocationStrategy: | |||
There was a problem hiding this comment.
allocationStrategy gains per-node only in the crds/ copy, which Helm doesn't touch on upgrade, so upgrading a release whose CRD predates the enum makes the API server reject the rendered per-node. Could we move this CRD into templates/ and gate it like the bundled monitor CRDs?
|
|
||
| printf "\n${Y}== Target Allocator CRD RBAC ==${N}\n" | ||
| # The TA needs customresourcedefinitions get;list;watch on the prometheus-CR path. | ||
| expect_count "CRD RBAC present when otelCI on" "$CRD_RBAC" 1 --set otelContainerInsights.enabled=true |
There was a problem hiding this comment.
The CRD_RBAC assertions on lines 76 to 78 expect customresourcedefinitions RBAC that lands in a separate branch, so this branch renders zero and set -euo pipefail fails the whole suite. Could we move them into that branch or guard them until the rule exists?
| otelContainerInsights.prometheusScrape.enabled are both true. | ||
| Returns the string "true" when CRDs should be rendered, empty otherwise. | ||
| */}} | ||
| {{- define "amazon-cloudwatch-observability.prometheusCRDsEnabled" -}} |
There was a problem hiding this comment.
prometheusCRDsEnabled only matches always/never exactly, so a typo like nevr falls through and silently bundles the CRDs when otelCI is on. Could we add a fail branch for anything that isn't auto, always, or never?
| the configured targetAgent, and at least one of serviceMonitor/podMonitor is enabled. | ||
| Accepts a dict with "agentName" (string) and "context" (root context $). | ||
| */}} | ||
| {{- define "cloudwatch-agent.otelCIScrapeEnabled" -}} |
There was a problem hiding this comment.
otelCIScrapeEnabled no longer short circuits when both serviceMonitor.enabled and podMonitor.enabled are false, so prometheusScrape.enabled=true renders an idle target-allocator that bundles CRDs but discovers nothing. Could we reject that both false case and add a matrix assertion?
…cture Re-sync aws-observability#332 onto the updated stack (aws-observability#329->aws-observability#330->aws-observability#331). Resolutions favor the settled older-PR fixes applied onto aws-observability#332's prometheusScrape.* restructure: - prometheusCRDsEnabled: keep aws-observability#331's explicit auto branch + invalid-value fail, gated on aws-observability#332's otelContainerInsights.enabled && prometheusScrape.enabled. - allocationStrategy: use aws-observability#332's precomputed $allocationStrategy (per-node on the otelCI path via prometheusScrape.allocationStrategy, consistent-hashing for direct-TA) -- supersedes aws-observability#330's ternary while preserving its intent. - Fix a stale old-key guard (otelContainerInsights.serviceMonitor.enabled) left by auto-merge in the prometheuscr scope-processor to prometheusScrape.enabled. - Keep aws-observability#330's SM/PM node-stamping removal; port aws-observability#331's GitOps opt-out caveat into the new prometheusScrape.crds doc. Verified: lint clean, CRD matrix 21/0, flag matrix 8/8.
…ion-scraper-routing Re-sync aws-observability#339 (scraper routing) onto the full updated stack. Preserve aws-observability#339's annotation-routing feature (scraperRole: cluster-scraper) while adopting the older/settled fixes: the prometheusScrape restructure, legacy-key aliases + deprecation notice, the serviceMonitorEnabled/podMonitorEnabled helpers for the SM/PM selector guards, the feature-gate/CRD-RBAC/render-once/v0.92.0-CRD fixes, and per-node scoping. Verified: lint clean, CRD matrix 24/0, flag matrix 8/8, scraperRole renders, legacy prometheusCRDs.install alias honored.
…ion-scraper-routing Propagates the both-false prometheusScrape validation (reject scrape.enabled with no monitors). # Conflicts: # charts/amazon-cloudwatch-observability/tests/prometheus_crds_matrix.sh
…ion-scraper-routing Propagates the needsCR least-privilege fix (require targetAllocator.enabled).
…ion-scraper-routing Brings in aws-observability#332 plus origin/main (including the resolved cloudwatch-agent-custom-resource.yaml conflict). The only conflict here was the otelCIScrapeEnabled doc comment; the merged text keeps this branch's two-agent description (targetAgent or clusterScraperAgent) and aws-observability#332's note that individual monitor types are not checked by this helper.
…ion-scraper-routing Brings in the full chain (aws-observability#332, aws-observability#331, aws-observability#330, aws-observability#329) and origin/main. The cluster-scraper OTEL config conflicted structurally: main added the Karpenter/KEDA solution pipelines (aws-observability#325, aws-observability#345) in the same receivers / processors / pipelines sections where this branch adds its prometheuscr blocks, and git interleaved the {{- if }}/{{- end }} boundaries. Rather than untangle the markers, the file was reconstructed from main's version with this branch's three self-contained, individually-gated prometheuscr blocks re-inserted at their anchors (after each kubeStateMetrics block). Verified: all five cluster-scraper pipelines render (prometheuscr, karpenter, keda, apiserver, kube_state_metrics), scraperRole is still set only on the cluster-scraper, and the TA ClusterRole/Binding still render exactly once.
|
Checklist posted for the PR author to move into the PR description under a PR Checklist
|
bd1b7f2 to
cc4de2a
Compare
…ights.prometheusScrape Collapses SM/PM scraping enablement into a single switch. otelContainerInsights.enabled: true now makes SM/PM scraping work end to end; prometheusScrape.enabled: false opts out while keeping the rest of OTEL Container Insights. BREAKING (unreleased keys): the former top-level prometheusCRDs key and otelContainerInsights.serviceMonitor / .podMonitor keys are MOVED, not aliased, to otelContainerInsights.prometheusScrape.*. Any values file setting the old paths needs updating. These keys have not shipped in a released chart version, so there is no external contract to preserve.
cc4de2a to
af86da1
Compare
Summary
Collapse the SM/PM scraping enablement into a single switch. Previously, turning on the
feature spanned several interacting flags (
prometheusCRDs.install,otelContainerInsights.serviceMonitor/podMonitor.enabled, deepagent.prometheus.targetAllocator.*). This consolidates them under one nested bundle:otelContainerInsights.enabled: truenow makes SM/PM scraping work end to end; a singleprometheusScrape.enabled: falseopts out while keeping the rest of OTEL Container Insights.Notes for reviewers
external contract to preserve — the old
prometheusCRDs/otelContainerInsights. serviceMonitor|podMonitortop-level keys are moved, not aliased._helpers.tpl(otelCIScrapeEnabled,prometheusCRDsEnabled) now readfrom the
prometheusScrapebundle.Dependencies
Top of the helm stack — refactors keys introduced by #329 (v2 OTLP path), #330
(per-node) and #331 (CRD bundling). Merge those first; this PR's diff includes them until
they land.
Testing
helm template:otelContainerInsights.enabled=true→ CRDs render (2), prometheuscr path renders,allocationStrategy: "per-node".+ prometheusScrape.enabled=false→ prometheuscr and bundled CRDs both drop to 0(scraping off, rest of CI intact).
helm lintclean (pre-existingfluent-bit-windowsregion warning is unrelated).