From 9ceaaa3e0b850ed44181c8620e08f0b9382ce97b Mon Sep 17 00:00:00 2001 From: zhenyus Date: Mon, 21 Apr 2025 17:28:25 +0800 Subject: [PATCH] fix(opentelemetry): restore and configure k8sattributes processor for enhanced metadata extraction Signed-off-by: zhenyus --- .../authentication/opentelemetry.yaml | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/freeleaps/helm-pkg/authentication/templates/authentication/opentelemetry.yaml b/freeleaps/helm-pkg/authentication/templates/authentication/opentelemetry.yaml index 6741b468..4ca3aaf1 100644 --- a/freeleaps/helm-pkg/authentication/templates/authentication/opentelemetry.yaml +++ b/freeleaps/helm-pkg/authentication/templates/authentication/opentelemetry.yaml @@ -29,35 +29,44 @@ spec: parse_from: body parse_to: attributes processors: - # k8sattributes: - # auth_type: serviceAccount - # wait_for_metadata: true - # wait_for_metadata_timeout: 10s - # passthrough: false - # extract: - # metadata: - # - k8s.pod.name - # - k8s.pod.ip - # - k8s.pod.uid - # - k8s.deployment.name - # - k8s.deployment.uid - # - k8s.namespace.name - # - k8s.node.name - # resource: - # attributes: - # - action: upsert - # key: application - # from_attribute: context.app - # - action: upsert - # key: environment - # from_attribute: context.env + k8sattributes: + auth_type: serviceAccount + wait_for_metadata: true + wait_for_metadata_timeout: 5s + passthrough: false + extract: + metadata: + - k8s.pod.name + - k8s.pod.ip + - k8s.pod.uid + - k8s.deployment.name + - k8s.deployment.uid + - k8s.namespace.name + - k8s.node.name + pod_association: + - sources: + - from: resource_attributes + name: k8s.pod.name + - sources: + - from: resource_attributes + name: k8s.pod.uid + - source: + - from: connection transform: log_statements: - context: log statements: - - set(log.body["kubernetes"], log.attributes["kubernetes"]) - set(resource.attributes["application"], log.attributes["context"]["app"]) - set(resource.attributes["environment"], log.attributes["context"]["env"]) + - set(resource.attributes["kubernetes_node_name"]) + - set(log.body["kubernetes"]["pod"], resource.attributes["k8s.pod.name"]) + - set(log.body["kubernetes"]["namespace"], resource.attributes["k8s.namespace.name"]) + - set(log.body["kubernetes"]["pod_ip"], resource.attributes["k8s.pod.ip"]) + - set(log.body["kubernetes"]["pod_uid"], resource.attributes["k8s.pod.uid"]) + - set(log.body["kubernetes"]["deployment"], resource.attributes["k8s.deployment.name"]) + - set(log.body["kubernetes"]["deployment_uid"], resource.attributes["k8s.deployment.uid"]) + - set(log.body["kubernetes"]["node"], resource.attributes["k8s.node.name"]) + - set(log.body["kubernetes"]["namespace"], resource.attributes["k8s.namespace.name"]) batch: send_batch_size: 5 timeout: 10s @@ -75,6 +84,6 @@ spec: pipelines: logs: receivers: [filelog] - processors: [transform, batch] + processors: [k8sattributes, transform, batch] exporters: [otlphttp/logs, debug] {{- end }} \ No newline at end of file