feat(opentelemetry): add additional Kubernetes labels and enhance logging attributes

This commit is contained in:
Nicolas 2025-09-28 09:07:42 +08:00
parent 38ae6e7b17
commit ec93fc987c

View File

@ -79,8 +79,20 @@ spec:
log_statements:
- context: log
statements:
- set(resource.attributes["application"], "central-storage")
# Set Grafana queryable labels
- set(resource.attributes["service_name"], "central-storage")
- set(resource.attributes["environment"], "{{ .Values.global.environment | default .Release.Namespace }}")
- set(resource.attributes["pod_name"], resource.attributes["k8s.pod.name"])
- set(resource.attributes["pod_ip"], resource.attributes["k8s.pod.ip"])
# Keep application for backward compatibility
- set(resource.attributes["application"], "central-storage")
# Set additional kubernetes labels
- set(resource.attributes["kubernetes_node_name"], resource.attributes["k8s.node.name"])
- set(resource.attributes["kubernetes_pod_name"], resource.attributes["k8s.pod.name"])
- set(resource.attributes["kubernetes_pod_ip"], resource.attributes["k8s.pod.ip"])
- set(resource.attributes["kubernetes_deployment_name"], resource.attributes["k8s.deployment.name"])
- set(resource.attributes["kubernetes_namespace"], resource.attributes["k8s.namespace.name"])
# Parse and enrich log body
- set(resource.attributes["body_json"], ParseJSON(log.body))
- set(resource.attributes["body_json"]["kubernetes"]["pod"], resource.attributes["k8s.pod.name"])
- set(resource.attributes["body_json"]["kubernetes"]["namespace"], resource.attributes["k8s.namespace.name"])