@@ -54,6 +54,34 @@ receivers:
5454 - {{ include " kube-state-metrics.name" . }}. {{ .Release.Namespace }}.svc :{{ .Values.kubeStateMetrics.service.port }}
5555{{- end }}
5656
57+ {{- if and .Values.otelContainerInsights.solutions.enabled .Values.otelContainerInsights.solutions.karpenter.enabled }}
58+ prometheus/cw_k8s_ci_v0_karpenter:
59+ config:
60+ scrape_configs:
61+ - job_name: karpenter
62+ scrape_interval: {{ .Values.otelContainerInsights.metricResolution }}
63+ scrape_timeout: {{ include " otel-container-insights.scrapeTimeout" . }}
64+ metrics_path: /metrics
65+ kubernetes_sd_configs:
66+ - role: pod
67+ namespaces:
68+ names:
69+ - {{ .Values.otelContainerInsights.solutions.karpenter.namespace }}
70+ relabel_configs:
71+ - source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
72+ regex: karpenter
73+ action: keep
74+ - source_labels: [__meta_kubernetes_pod_container_port_name]
75+ regex: http-metrics
76+ action: keep
77+ - source_labels: [__meta_kubernetes_pod_name]
78+ target_label: pod
79+ - source_labels: [__meta_kubernetes_namespace]
80+ target_label: namespace
81+ - source_labels: [__meta_kubernetes_pod_node_name]
82+ target_label: node
83+ {{- end }}
84+
5785{{- if and .Values.otelContainerInsights.solutions.enabled .Values.otelContainerInsights.solutions.keda.enabled }}
5886 prometheus/cw_k8s_ci_v0_keda:
5987 config:
@@ -168,7 +196,70 @@ processors:
168196 - set(attributes[" cloudwatch.pipeline" ], " kube-state-metrics" )
169197{{- end }}
170198
199+ {{- if and .Values.otelContainerInsights.solutions.enabled .Values.otelContainerInsights.solutions.karpenter.enabled }}
200+ transform/cw_k8s_ci_v0_set_scope_karpenter:
201+ error_mode: ignore
202+ metric_statements:
203+ - context: scope
204+ statements:
205+ - set(scope.name , " github.com/aws/karpenter" )
206+ - set(scope.schema_url , " " )
207+ - set(attributes[" cloudwatch.source" ], " cloudwatch-agent" )
208+ - set(attributes[" cloudwatch.solution" ], " k8s-otel-container-insights" )
209+ - set(attributes[" cloudwatch.pipeline" ], " karpenter" )
210+
211+ # Promote scraped pod/namespace/node labels to OTel K8s resource attributes.
212+ # This allows the shared k8sattributes processor to enrich with deployment/workload info.
213+ groupbyattrs/cw_k8s_ci_v0_karpenter:
214+ keys:
215+ - pod
216+ - namespace
217+ - node
218+
219+ transform/cw_k8s_ci_v0_karpenter_promote:
220+ error_mode: ignore
221+ metric_statements:
222+ - context: resource
223+ statements:
224+ - set(attributes[" k8s.pod.name" ], attributes[" pod" ]) where attributes[" pod" ] != nil
225+ - set(attributes[" k8s.namespace.name" ], attributes[" namespace" ]) where attributes[" namespace" ] != nil
226+ - set(attributes[" k8s.node.name" ], attributes[" node" ]) where attributes[" node" ] != nil
227+ # Remove deprecated/unwanted attributes auto-injected by the Prometheus receiver.
228+ - delete_key(attributes, " net.host.name" ) where attributes[" net.host.name" ] != nil
229+ - delete_key(attributes, " net.host.port" ) where attributes[" net.host.port" ] != nil
230+ - delete_key(attributes, " url.scheme" ) where attributes[" url.scheme" ] != nil
231+ - context: datapoint
232+ statements:
233+ - set(attributes[" pod" ], resource.attributes [" pod" ]) where resource.attributes [" pod" ] != nil
234+ - set(attributes[" namespace" ], resource.attributes [" namespace" ]) where resource.attributes [" namespace" ] != nil
235+ - set(attributes[" node" ], resource.attributes [" node" ]) where resource.attributes [" node" ] != nil
236+
237+ # Karpenter-specific resource detection: only cloud-level attributes (region, account).
238+ # No host/AZ attributes — those would incorrectly reflect the scraper's node, not Karpenter's.
239+ resourcedetection/cw_k8s_ci_v0_karpenter:
240+ detectors: [eks, ec2]
241+ ec2:
242+ resource_attributes:
243+ host.id : { enabled: false }
244+ host.type : { enabled: false }
245+ host.name : { enabled: false }
246+ host.image.id : { enabled: false }
247+ cloud.provider : { enabled: true }
248+ cloud.platform : { enabled: true }
249+ cloud.region : { enabled: true }
250+ cloud.availability_zone : { enabled: false }
251+ cloud.account.id : { enabled: true }
252+ {{- end }}
253+
171254{{- if and .Values.otelContainerInsights.solutions.enabled .Values.otelContainerInsights.solutions.keda.enabled }}
255+ # Drop generic client-go / control-plane metrics that KEDA's Go runtime exposes.
256+ # These conflict with the apiserver pipeline which owns them with a different scope.
257+ filter/cw_k8s_ci_v0_keda_drop_non_keda:
258+ error_mode: ignore
259+ metrics:
260+ metric:
261+ - IsMatch(name, " ^(rest_client_.*|apiserver_.*|workqueue_.*|process_.*|go_.*)$" )
262+
172263 transform/cw_k8s_ci_v0_set_scope_keda:
173264 error_mode: ignore
174265 metric_statements:
@@ -527,11 +618,33 @@ service:
527618 exporters:
528619 - otlphttp/cw_k8s_ci_v0_cwotel
529620{{- end }}
621+ {{- if and .Values.otelContainerInsights.solutions.enabled .Values.otelContainerInsights.solutions.karpenter.enabled }}
622+ metrics/cw_k8s_ci_v0_karpenter:
623+ receivers: [prometheus/cw_k8s_ci_v0_karpenter]
624+ processors:
625+ - filter/cw_k8s_ci_v0_scrape_metadata
626+ - transform/cw_k8s_ci_v0_set_unit
627+ - metricstarttime/cw_k8s_ci_v0
628+ - transform/cw_k8s_ci_v0_set_scope_karpenter
629+ - transform/cw_k8s_ci_v0_set_cluster_name
630+ - groupbyattrs/cw_k8s_ci_v0_karpenter
631+ - transform/cw_k8s_ci_v0_karpenter_promote
632+ - k8sattributes/cw_k8s_ci_v0_pod
633+ - transform/cw_k8s_ci_v0_set_workload
634+ - resourcedetection/cw_k8s_ci_v0_karpenter
635+ - transform/cw_k8s_ci_v0_clear_schema_url
636+ - transform/cw_k8s_ci_v0_set_cloud_resource_id
637+ - awsattributelimit/cw_k8s_ci_v0
638+ - batch/cw_k8s_ci_v0_cwotel
639+ exporters:
640+ - otlphttp/cw_k8s_ci_v0_cwotel
641+ {{- end }}
530642{{- if and .Values.otelContainerInsights.solutions.enabled .Values.otelContainerInsights.solutions.keda.enabled }}
531643 metrics/cw_k8s_ci_v0_keda:
532644 receivers: [prometheus/cw_k8s_ci_v0_keda]
533645 processors:
534646 - filter/cw_k8s_ci_v0_scrape_metadata
647+ - filter/cw_k8s_ci_v0_keda_drop_non_keda
535648 - transform/cw_k8s_ci_v0_set_unit
536649 - metricstarttime/cw_k8s_ci_v0
537650 - transform/cw_k8s_ci_v0_set_scope_keda
0 commit comments