@@ -3,6 +3,11 @@ extensions:
33 sigv4auth/cw_k8s_ci_v0_cwotel:
44 region: {{ .Values.region }}
55 service: monitoring
6+ {{- if .Values.otelContainerInsights.events.enabled }}
7+ sigv4auth/cw_k8s_ci_v0_cwlogs:
8+ region: {{ .Values.region }}
9+ service: logs
10+ {{- end }}
611 nodemetadatacache/cw_k8s_ci_v0:
712 namespace: {{ .Release.Namespace }}
813
@@ -48,6 +53,12 @@ receivers:
4853 - {{ include " kube-state-metrics.name" . }}. {{ .Release.Namespace }}.svc :{{ .Values.kubeStateMetrics.service.port }}
4954{{- end }}
5055
56+ {{- if .Values.otelContainerInsights.events.enabled }}
57+ k8s_events/cw_k8s_ci_v0:
58+ auth_type: serviceAccount
59+ namespaces: []
60+ {{- end }}
61+
5162processors:
5263 filter/cw_k8s_ci_v0_scrape_metadata:
5364 error_mode: ignore
@@ -216,7 +227,9 @@ processors:
216227 - set(attributes[" cronjob" ], resource.attributes [" cronjob" ]) where resource.attributes [" cronjob" ] != nil
217228 - set(attributes[" owner_name" ], resource.attributes [" owner_name" ]) where resource.attributes [" owner_name" ] != nil
218229 - set(attributes[" owner_kind" ], resource.attributes [" owner_kind" ]) where resource.attributes [" owner_kind" ] != nil
230+ {{- end }}
219231
232+ {{- if or .Values.kubeStateMetrics.enabled .Values.otelContainerInsights.events.enabled }}
220233 k8sattributes/cw_k8s_ci_v0_pod:
221234 auth_type: serviceAccount
222235 passthrough: false
@@ -348,17 +361,87 @@ processors:
348361 send_batch_max_size: 500
349362 timeout: 10s
350363
364+ {{- if .Values.otelContainerInsights.events.enabled }}
365+ transform/cw_k8s_ci_v0_events_parse:
366+ error_mode: ignore
367+ log_statements:
368+ - context: log
369+ statements:
370+ - set(resource.attributes [" k8s.namespace.name" ], attributes[" k8s.namespace.name" ]) where attributes[" k8s.namespace.name" ] != nil
371+ - set(resource.attributes [" k8s.pod.name" ], resource.attributes [" k8s.object.name" ]) where resource.attributes [" k8s.object.kind" ] == " Pod" and resource.attributes [" k8s.object.name" ] != nil
372+
373+ transform/cw_k8s_ci_v0_events_set_cluster_name:
374+ error_mode: ignore
375+ log_statements:
376+ - context: log
377+ statements:
378+ - set(resource.attributes [" k8s.cluster.name" ], " {{ .Values.clusterName }}" )
379+ - set(resource.attributes [" aws.log.group.names" ], " /aws/containerinsights/{{ .Values.clusterName }}/events" )
380+
381+ transform/cw_k8s_ci_v0_events_set_workload:
382+ error_mode: ignore
383+ log_statements:
384+ - context: log
385+ statements:
386+ - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.deployment.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.deployment.name" ] != nil
387+ - set(resource.attributes [" k8s.workload.type" ], " Deployment" ) where resource.attributes [" k8s.workload.type" ] == nil and resource.attributes [" k8s.deployment.name" ] != nil
388+ - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.statefulset.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.statefulset.name" ] != nil
389+ - set(resource.attributes [" k8s.workload.type" ], " StatefulSet" ) where resource.attributes [" k8s.workload.type" ] == nil and resource.attributes [" k8s.statefulset.name" ] != nil
390+ - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.daemonset.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.daemonset.name" ] != nil
391+ - set(resource.attributes [" k8s.workload.type" ], " DaemonSet" ) where resource.attributes [" k8s.workload.type" ] == nil and resource.attributes [" k8s.daemonset.name" ] != nil
392+ - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.job.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.job.name" ] != nil
393+ - set(resource.attributes [" k8s.workload.type" ], " Job" ) where resource.attributes [" k8s.workload.type" ] == nil and resource.attributes [" k8s.job.name" ] != nil
394+ - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.cronjob.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.cronjob.name" ] != nil
395+ - set(resource.attributes [" k8s.workload.type" ], " CronJob" ) where resource.attributes [" k8s.workload.type" ] == nil and resource.attributes [" k8s.cronjob.name" ] != nil
396+ - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.replicaset.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.replicaset.name" ] != nil
397+ - set(resource.attributes [" k8s.workload.type" ], " ReplicaSet" ) where resource.attributes [" k8s.workload.type" ] == nil and resource.attributes [" k8s.replicaset.name" ] != nil
398+
399+ transform/cw_k8s_ci_v0_events_set_scope:
400+ error_mode: ignore
401+ log_statements:
402+ - context: scope
403+ statements:
404+ - set(scope.name , " k8s.io/events" )
405+ - set(attributes[" cloudwatch.source" ], " cloudwatch-agent" )
406+ - set(attributes[" cloudwatch.solution" ], " k8s-otel-container-insights" )
407+ - set(attributes[" cloudwatch.pipeline" ], " events" )
408+
409+ transform/cw_k8s_ci_v0_events_set_cloud_resource_id:
410+ error_mode: ignore
411+ log_statements:
412+ - context: resource
413+ statements:
414+ - set(resource.attributes [" cloud.resource_id" ], Concat([" arn:aws:eks:" , resource.attributes [" cloud.region" ], " :" , resource.attributes [" cloud.account.id" ], " :cluster/" , resource.attributes [" k8s.cluster.name" ]], " " ))
415+ where resource.attributes [" cloud.region" ] != nil and resource.attributes [" cloud.account.id" ] != nil and resource.attributes [" k8s.cluster.name" ] != nil
416+ {{- end }}
417+
351418exporters:
352419 otlphttp/cw_k8s_ci_v0_cwotel:
353420 endpoint: {{ if .Values.otelContainerInsights.cloudwatchMetricsEndpoint }}{{ .Values.otelContainerInsights.cloudwatchMetricsEndpoint | quote }}{{ else }}" https://monitoring.{{ .Values.region }}.amazonaws.com:443" {{ end }}
354421 tls:
355422 insecure: false
356423 auth:
357424 authenticator: sigv4auth/cw_k8s_ci_v0_cwotel
425+ {{- if .Values.otelContainerInsights.events.enabled }}
426+ otlphttp/cw_k8s_ci_v0_cwlogs:
427+ endpoint: " https://logs.{{ .Values.region }}.amazonaws.com:443"
428+ headers:
429+ x-aws-log-group: " /aws/containerinsights/{{ .Values.clusterName }}/events"
430+ x-aws-log-stream: " events"
431+ x-aws-log-group-create: " true"
432+ x-aws-log-stream-create: " true"
433+ tls:
434+ insecure: false
435+ auth:
436+ authenticator: sigv4auth/cw_k8s_ci_v0_cwlogs
437+ {{- end }}
358438
359439service:
360440 extensions:
361441 - sigv4auth/cw_k8s_ci_v0_cwotel
442+ {{- if .Values.otelContainerInsights.events.enabled }}
443+ - sigv4auth/cw_k8s_ci_v0_cwlogs
444+ {{- end }}
362445 - nodemetadatacache/cw_k8s_ci_v0
363446 pipelines:
364447 metrics/cw_k8s_ci_v0_apiserver:
@@ -405,5 +488,22 @@ service:
405488 exporters:
406489 - otlphttp/cw_k8s_ci_v0_cwotel
407490{{- end }}
491+ {{- if .Values.otelContainerInsights.events.enabled }}
492+ logs/cw_k8s_ci_v0_events:
493+ receivers: [k8s_events/cw_k8s_ci_v0]
494+ processors:
495+ - transform/cw_k8s_ci_v0_events_parse
496+ - transform/cw_k8s_ci_v0_events_set_cluster_name
497+ - k8sattributes/cw_k8s_ci_v0_pod
498+ - k8sattributes/cw_k8s_ci_v0_node
499+ - transform/cw_k8s_ci_v0_events_set_workload
500+ - resourcedetection/cw_k8s_ci_v0
501+ - nodemetadataenricher/cw_k8s_ci_v0
502+ - transform/cw_k8s_ci_v0_events_set_scope
503+ - transform/cw_k8s_ci_v0_events_set_cloud_resource_id
504+ - batch/cw_k8s_ci_v0_cwotel
505+ exporters:
506+ - otlphttp/cw_k8s_ci_v0_cwlogs
507+ {{- end }}
408508{{- end -}}
409509
0 commit comments