-
Notifications
You must be signed in to change notification settings - Fork 47
[amazon-cloudwatch-observability] feat: add ServiceMonitor/PodMonitor v2 OTLP scraping path #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3e61e2e
0222e9f
48e8330
32b6ae5
ee2df6e
cd3fb5e
7911c6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,23 @@ receivers: | |
| - targets: | ||
| - ${env:HOST_IP}:10250 | ||
|
|
||
| {{- if or .Values.otelContainerInsights.serviceMonitor.enabled .Values.otelContainerInsights.podMonitor.enabled }} | ||
| # ServiceMonitor/PodMonitor scraping via the Target Allocator (prometheusCR discovery). | ||
| # The Target Allocator deployed for the targetAgent serves the scrape jobs derived from | ||
| # ServiceMonitor/PodMonitor CRs; this receiver pulls this collector's assigned shard and | ||
| # routes the series into the v2 OTLP pipeline (-> CloudWatch/Zeus). Requires the Target | ||
| # Allocator + prometheusCR to be enabled for the targetAgent and the POD_NAME env (set below). | ||
| prometheus/cw_k8s_ci_v0_prometheuscr: | ||
| target_allocator: | ||
| endpoint: https://{{ .Values.otelContainerInsights.targetAgent }}-target-allocator-service:80 | ||
| interval: {{ .Values.otelContainerInsights.metricResolution }} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed they're distinct knobs. I'd rather not add a second field preemptively, but the shared value being non-obvious is fair |
||
| collector_id: ${env:POD_NAME} | ||
| tls: | ||
| ca_file: /etc/amazon-cloudwatch-observability-agent-cert/tls-ca.crt | ||
| cert_file: /etc/amazon-cloudwatch-observability-agent-ta-client-cert/client.crt | ||
| key_file: /etc/amazon-cloudwatch-observability-agent-ta-client-cert/client.key | ||
| {{- end }} | ||
|
|
||
| {{- if .Values.dcgmExporter.enabled }} | ||
| prometheus/cw_k8s_ci_v0_dcgm: | ||
| config: | ||
|
|
@@ -329,6 +346,18 @@ processors: | |
| - set(attributes["cloudwatch.solution"], "k8s-otel-container-insights") | ||
| - set(attributes["cloudwatch.pipeline"], "efa") | ||
|
|
||
| {{- if or .Values.otelContainerInsights.serviceMonitor.enabled .Values.otelContainerInsights.podMonitor.enabled }} | ||
| transform/cw_k8s_ci_v0_set_scope_prometheuscr: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scraping receiver and pipeline are guarded on |
||
| error_mode: ignore | ||
| metric_statements: | ||
| - context: scope | ||
| statements: | ||
| - set(scope.schema_url, "") | ||
| - set(attributes["cloudwatch.source"], "cloudwatch-agent") | ||
| - set(attributes["cloudwatch.solution"], "k8s-otel-container-insights") | ||
| - set(attributes["cloudwatch.pipeline"], "prometheus-cr") | ||
| {{- end }} | ||
|
|
||
| transform/cw_k8s_ci_v0_set_scope_ebs_csi: | ||
| error_mode: ignore | ||
| metric_statements: | ||
|
|
@@ -427,6 +456,8 @@ processors: | |
| - k8s.job.name | ||
| - k8s.cronjob.name | ||
| labels: | ||
| # $$$1 -> literal $1 backreference (group 1 = label key). The agent's OTel confmap | ||
| # resolves it twice (expandconverter + resolver), each collapsing $$->$; Helm leaves it as-is. | ||
| - tag_name: "k8s.pod.label.$$$1" | ||
| key_regex: "(.*)" | ||
| from: pod | ||
|
|
@@ -829,6 +860,23 @@ service: | |
| exporters: | ||
| - otlphttp/cw_k8s_ci_v0_metrics_dest | ||
|
|
||
| {{- if or .Values.otelContainerInsights.serviceMonitor.enabled .Values.otelContainerInsights.podMonitor.enabled }} | ||
| metrics/cw_k8s_ci_v0_prometheuscr: | ||
| receivers: [prometheus/cw_k8s_ci_v0_prometheuscr] | ||
| # Phase 1: minimal chain to get ServiceMonitor/PodMonitor series flowing to v2. | ||
| # Richer OTel label/metadata enrichment (k8sattributes pod/node, workload, etc.) | ||
| # is intentionally deferred to the Phase 3 enrichment work. | ||
| processors: | ||
| - filter/cw_k8s_ci_v0_scrape_metadata | ||
| - metricstarttime/cw_k8s_ci_v0 | ||
| - transform/cw_k8s_ci_v0_set_cluster_name | ||
| - transform/cw_k8s_ci_v0_set_scope_prometheuscr | ||
| - resourcedetection/cw_k8s_ci_v0 | ||
| - batch/cw_k8s_ci_v0_metrics_dest | ||
| exporters: | ||
| - otlphttp/cw_k8s_ci_v0_metrics_dest | ||
| {{- end }} | ||
|
|
||
| {{- if .Values.dcgmExporter.enabled }} | ||
| metrics/cw_k8s_ci_v0_dcgm: | ||
| receivers: [prometheus/cw_k8s_ci_v0_dcgm] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,22 @@ | ||
| {{- if .Values.agent.enabled }} | ||
| {{- /* | ||
| All Target Allocators (targetAgent and clusterScraperAgent) default to the same | ||
| ServiceAccount (target-allocator-service-acct; see operator serviceaccount.go), so a single | ||
| ClusterRole covers every TA. Pre-scan the agents to decide whether any TA (and any | ||
| prometheusCR discovery) is enabled, then render exactly once to avoid duplicate-name objects. | ||
| */}} | ||
| {{- $needsTA := false }} | ||
| {{- $needsCR := false }} | ||
| {{- range $i, $customAgent := .Values.agents }} | ||
| {{- if and (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "enabled")) $customAgent.prometheus.targetAllocator.enabled }} | ||
| {{- $otelCIScrape := eq (include "cloudwatch-agent.otelCIScrapeEnabled" (dict "agentName" $customAgent.name "context" $)) "true" }} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This renders the ClusterRole inside |
||
| {{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "enabled") $customAgent.prometheus.targetAllocator.enabled) $otelCIScrape }} | ||
| {{- $needsTA = true }} | ||
| {{- end }} | ||
| {{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "prometheusCR") $customAgent.prometheus.targetAllocator.prometheusCR.enabled) $otelCIScrape }} | ||
| {{- $needsCR = true }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if $needsTA }} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
|
|
@@ -22,12 +38,14 @@ rules: | |
| verbs: ["get", "list", "watch"] | ||
| - nonResourceURLs: ["/metrics"] | ||
| verbs: ["get"] | ||
| {{- if and (hasKey ($customAgent.prometheus.targetAllocator) "prometheusCR") $customAgent.prometheus.targetAllocator.prometheusCR.enabled }} | ||
| {{- if $needsCR }} | ||
| - apiGroups: [ "monitoring.coreos.com"] | ||
| resources: ["podmonitors", "servicemonitors"] | ||
| verbs: ["get", "list", "watch"] | ||
| # TA watches the SM/PM CRDs to start/stop informers as they appear or disappear (read-only). | ||
| - apiGroups: [ "apiextensions.k8s.io" ] | ||
| resources: ["customresourcedefinitions"] | ||
| verbs: ["get", "list", "watch"] | ||
| {{- end }} | ||
| {{- end }} | ||
| --- | ||
| {{- end }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1161,6 +1161,17 @@ otelContainerInsights: | |
| ## Only takes effect when otelContainerInsights.enabled is true. | ||
| logs: | ||
| enabled: true | ||
| ## Prometheus ServiceMonitor scraping (monitoring.coreos.com/v1) via the Target | ||
| ## Allocator's prometheusCR discovery. Defaults to true: when | ||
| ## otelContainerInsights is enabled, ServiceMonitor scraping is on unless | ||
| ## explicitly disabled here. Only takes effect when otelContainerInsights.enabled is true. | ||
| serviceMonitor: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default-on behavior is intentional, the product goal is that enabling otelContainerInsights gives you working SM/PM scraping out of the box, and the surrounding work is built to make that safe: the operator's CRD-resilience change(#394) makes missing CRDs non-fatal (no crash/loop), and CRD bundling (#331) puts the CRDs in-cluster. So I'd like to keep SM/PM default-on rather than invert to opt-in. |
||
| enabled: true | ||
| ## Prometheus PodMonitor scraping (monitoring.coreos.com/v1) via the Target | ||
| ## Allocator's prometheusCR discovery. Defaults to true (see serviceMonitor note). | ||
| ## Only takes effect when otelContainerInsights.enabled is true. | ||
| podMonitor: | ||
| enabled: true | ||
| ## The agent in the agents array that receives node-level OTEL Container Insights config. | ||
| targetAgent: "cloudwatch-agent" | ||
| ## The agent in the agents array that receives cluster-level OTEL Container Insights config (apiserver, kube-state-metrics scraping). | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper reads
otelContainerInsights.serviceMonitor.enableddirectly. Fine today since the PR ships those keys as defaults, but it goes nil if a user replaces the whole map, so adigwith a default fallback might be safer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the subkeys ship as chart defaults and Helm deep-merges them, they're present under any partial override, so this is safe as-is I'll leave the direct access