From 70fb9d36b983b4d1beb9da409ec7bbda7be4a373 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 29 Jun 2023 08:40:11 +0200 Subject: [PATCH] Set cluster_name for host logs too if renameFieldsSck is enabled (#837) Up to now the cluster_name field was only set in `resource/logs`. This snippet was only included for the container logs, but not for host logs (files, journald). This change moves the cluster_name field to the `resource` snippet, which is according inline comment used for all things that pass through otel. Fixes #682 --- CHANGELOG.md | 4 ++++ .../splunk-otel-collector/templates/config/_common.tpl | 5 ----- .../templates/config/_otel-agent.tpl | 9 +++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55f4d4d74c..18ffc9109d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Fixed + +- Set cluster_name for host logs too if renameFieldsSck is enabled [#837](https://github.com/signalfx/splunk-otel-collector-chart/pull/837) + ### Added - Update PodDisruptionBudgets API version to allow both `policy/v1beta1` and `policy/v1` [#835](https://github.com/signalfx/splunk-otel-collector-chart/pull/835) diff --git a/helm-charts/splunk-otel-collector/templates/config/_common.tpl b/helm-charts/splunk-otel-collector/templates/config/_common.tpl index 79b8b1a21e..fafb533542 100644 --- a/helm-charts/splunk-otel-collector/templates/config/_common.tpl +++ b/helm-charts/splunk-otel-collector/templates/config/_common.tpl @@ -160,9 +160,6 @@ resource/logs: - key: container_name from_attribute: k8s.container.name action: upsert - - key: cluster_name - from_attribute: k8s.cluster.name - action: upsert - key: container_id from_attribute: container.id action: upsert @@ -186,8 +183,6 @@ resource/logs: {{- if not .Values.splunkPlatform.fieldNameConvention.keepOtelConvention }} - key: k8s.container.name action: delete - - key: k8s.cluster.name - action: delete - key: container.id action: delete - key: k8s.pod.name diff --git a/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl b/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl index 0e381a40c9..446b1e8b34 100644 --- a/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl +++ b/helm-charts/splunk-otel-collector/templates/config/_otel-agent.tpl @@ -527,6 +527,15 @@ processors: key: "{{ .name }}" value: "{{ .value }}" {{- end }} + {{- if .Values.splunkPlatform.fieldNameConvention.renameFieldsSck }} + - key: cluster_name + from_attribute: k8s.cluster.name + action: upsert + {{- if not .Values.splunkPlatform.fieldNameConvention.keepOtelConvention }} + - key: k8s.cluster.name + action: delete + {{- end }} + {{- end }} # Resource attributes specific to the agent itself. resource/add_agent_k8s: