Skip to content

Commit c626240

Browse files
Merge otel-ci-smpm-scrape-path (aws-observability#329) into helm-per-node-allocation
Re-sync aws-observability#330 onto the updated scraping-path branch: inherit the feature-gate ID fix, co-gated CRD RBAC render-once ClusterRole/Binding, the $$$1 comment correction, and the prometheuscr scope-processor guard, alongside aws-observability#330's per-node work.
2 parents d8a49d3 + 7911c6c commit c626240

5 files changed

Lines changed: 37 additions & 7 deletions

File tree

charts/amazon-cloudwatch-observability/templates/linux/_otel-container-insights-cluster-scraper-config.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ processors:
231231
- k8s.job.name
232232
- k8s.cronjob.name
233233
labels:
234-
# $$$1 is Helm escaping: $$$$$ (Helm) → $ (OTel env resolver) → literal $1 backreference
234+
# $$$1 -> literal $1 backreference (group 1 = label key). The agent's OTel confmap
235+
# resolves it twice (expandconverter + resolver), each collapsing $$->$; Helm leaves it as-is.
235236
- tag_name: "k8s.pod.label.$$$1"
236237
key_regex: "(.*)"
237238
from: pod

charts/amazon-cloudwatch-observability/templates/linux/_otel-container-insights-config.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ processors:
346346
- set(attributes["cloudwatch.solution"], "k8s-otel-container-insights")
347347
- set(attributes["cloudwatch.pipeline"], "efa")
348348
349+
{{- if or .Values.otelContainerInsights.serviceMonitor.enabled .Values.otelContainerInsights.podMonitor.enabled }}
349350
transform/cw_k8s_ci_v0_set_scope_prometheuscr:
350351
error_mode: ignore
351352
metric_statements:
@@ -355,6 +356,7 @@ processors:
355356
- set(attributes["cloudwatch.source"], "cloudwatch-agent")
356357
- set(attributes["cloudwatch.solution"], "k8s-otel-container-insights")
357358
- set(attributes["cloudwatch.pipeline"], "prometheus-cr")
359+
{{- end }}
358360
359361
transform/cw_k8s_ci_v0_set_scope_ebs_csi:
360362
error_mode: ignore
@@ -454,6 +456,8 @@ processors:
454456
- k8s.job.name
455457
- k8s.cronjob.name
456458
labels:
459+
# $$$1 -> literal $1 backreference (group 1 = label key). The agent's OTel confmap
460+
# resolves it twice (expandconverter + resolver), each collapsing $$->$; Helm leaves it as-is.
457461
- tag_name: "k8s.pod.label.$$$1"
458462
key_regex: "(.*)"
459463
from: pod

charts/amazon-cloudwatch-observability/templates/operator-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
- "--auto-instrumentation-dotnet-image={{ template "auto-instrumentation-dotnet.image" . }}"
3838
- "--auto-instrumentation-nodejs-image={{ template "auto-instrumentation-nodejs.image" . }}"
3939
- "--target-allocator-image={{ template "target-allocator.image" (merge .Values.agent.prometheus.targetAllocator.image (dict "region" $.Values.region)) }}"
40-
- "--feature-gates=operator.autoinstrumentation.multi-instrumentation,operator.autoinstrumentation.multi-instrumentation.skip-container-validation"
40+
- "--feature-gates=operator.autoinstrumentation.multiinstrumentation,operator.autoinstrumentation.multiinstrumentation.skipcontainervalidation"
4141
command:
4242
- /manager
4343
name: manager

charts/amazon-cloudwatch-observability/templates/target-allocator-clusterrole.yaml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
{{- if .Values.agent.enabled }}
2+
{{- /*
3+
All Target Allocators (targetAgent and clusterScraperAgent) default to the same
4+
ServiceAccount (target-allocator-service-acct; see operator serviceaccount.go), so a single
5+
ClusterRole covers every TA. Pre-scan the agents to decide whether any TA (and any
6+
prometheusCR discovery) is enabled, then render exactly once to avoid duplicate-name objects.
7+
*/}}
8+
{{- $needsTA := false }}
9+
{{- $needsCR := false }}
210
{{- range $i, $customAgent := .Values.agents }}
311
{{- $otelCIScrape := eq (include "cloudwatch-agent.otelCIScrapeEnabled" (dict "agentName" $customAgent.name "context" $)) "true" }}
412
{{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "enabled") $customAgent.prometheus.targetAllocator.enabled) $otelCIScrape }}
13+
{{- $needsTA = true }}
14+
{{- end }}
15+
{{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "prometheusCR") $customAgent.prometheus.targetAllocator.prometheusCR.enabled) $otelCIScrape }}
16+
{{- $needsCR = true }}
17+
{{- end }}
18+
{{- end }}
19+
{{- if $needsTA }}
520
apiVersion: rbac.authorization.k8s.io/v1
621
kind: ClusterRole
722
metadata:
@@ -23,12 +38,14 @@ rules:
2338
verbs: ["get", "list", "watch"]
2439
- nonResourceURLs: ["/metrics"]
2540
verbs: ["get"]
26-
{{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "prometheusCR") $customAgent.prometheus.targetAllocator.prometheusCR.enabled) $otelCIScrape }}
41+
{{- if $needsCR }}
2742
- apiGroups: [ "monitoring.coreos.com"]
2843
resources: ["podmonitors", "servicemonitors"]
2944
verbs: ["get", "list", "watch"]
45+
# TA watches the SM/PM CRDs to start/stop informers as they appear or disappear (read-only).
46+
- apiGroups: [ "apiextensions.k8s.io" ]
47+
resources: ["customresourcedefinitions"]
48+
verbs: ["get", "list", "watch"]
3049
{{- end }}
3150
{{- end }}
32-
---
3351
{{- end }}
34-
{{- end }}

charts/amazon-cloudwatch-observability/templates/target-allocator-clusterrolebinding.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{{- if .Values.agent.enabled }}
2+
{{- /*
3+
Render a single ClusterRoleBinding for the shared Target Allocator ServiceAccount
4+
(target-allocator-service-acct), used by every TA (targetAgent and clusterScraperAgent).
5+
Pre-scan the agents to decide whether any TA is enabled, then render exactly once.
6+
*/}}
7+
{{- $needsTA := false }}
28
{{- range $i, $customAgent := .Values.agents }}
39
{{- $otelCIScrape := eq (include "cloudwatch-agent.otelCIScrapeEnabled" (dict "agentName" $customAgent.name "context" $)) "true" }}
410
{{- if or (and (hasKey ($customAgent.prometheus) "targetAllocator") (hasKey ($customAgent.prometheus.targetAllocator) "enabled") $customAgent.prometheus.targetAllocator.enabled) $otelCIScrape }}
11+
{{- $needsTA = true }}
12+
{{- end }}
13+
{{- end }}
14+
{{- if $needsTA }}
515
apiVersion: rbac.authorization.k8s.io/v1
616
kind: ClusterRoleBinding
717
metadata:
@@ -17,6 +27,4 @@ subjects:
1727
name: "target-allocator-service-acct"
1828
namespace: {{ $.Release.Namespace }}
1929
{{- end }}
20-
---
2130
{{- end }}
22-
{{- end }}

0 commit comments

Comments
 (0)