From ef5c8921373ec4e814393efe2919198ec70def46 Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Wed, 14 Aug 2024 15:06:04 +0200 Subject: [PATCH] add K8s resoure attributes to apm services --- .../elastic-helm/configmap-daemonset.yaml | 2 +- kubernetes/elastic-helm/deployment.yaml | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/kubernetes/elastic-helm/configmap-daemonset.yaml b/kubernetes/elastic-helm/configmap-daemonset.yaml index 597a0f91f2..ab55437fa1 100644 --- a/kubernetes/elastic-helm/configmap-daemonset.yaml +++ b/kubernetes/elastic-helm/configmap-daemonset.yaml @@ -37,7 +37,7 @@ data: resourcedetection/gcp: detectors: [env, gcp] timeout: 2s - override: false + override: true resource/k8s: attributes: - key: service.name diff --git a/kubernetes/elastic-helm/deployment.yaml b/kubernetes/elastic-helm/deployment.yaml index 3df52a60f9..33a9871c5a 100644 --- a/kubernetes/elastic-helm/deployment.yaml +++ b/kubernetes/elastic-helm/deployment.yaml @@ -2,6 +2,35 @@ default: image: repository: ghcr.io/elastic/opentelemetry-demo tag: 1.11.2 + envOverrides: + - name: OTEL_SERVICE_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.labels['app.kubernetes.io/component'] + - name: OTEL_K8S_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: OTEL_K8S_NODE_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: spec.nodeName + - name: OTEL_K8S_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: OTEL_K8S_POD_UID + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.uid + - name: OTEL_RESOURCE_ATTRIBUTES + value: 'service.name=$(OTEL_SERVICE_NAME),service.instance.id=$(OTEL_K8S_POD_UID),service.namespace=opentelemetry-demo,k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_K8S_NODE_NAME),k8s.pod.name=$(OTEL_K8S_POD_NAME)' + opentelemetry-collector: image: