fix(opentelemetry): update log transformation to use resource attributes for application and environment

Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
zhenyus 2025-04-21 17:17:40 +08:00
parent 802b9bf8ba
commit 473f5cea54
2 changed files with 12 additions and 10 deletions

View File

@ -348,13 +348,6 @@ loki:
query_timeout: 300s
volume_enabled: true
allow_structured_metadata: true
otlp_config:
resource_attributes:
attributes_config:
- action: index_label
regex: app
- action: index_label
regex: environment
# -- Provides a reloadable runtime configuration file for some specific configuration
runtimeConfig: {}
# -- Check https://grafana.com/docs/loki/latest/configuration/#common_config for more info on how to provide a common configuration
@ -554,7 +547,15 @@ loki:
frontend_worker:
scheduler_address: '{{ include "loki.querySchedulerAddress" . }}'
# -- Optional distributor configuration
distributor: {}
distributor:
default_resource_attributes_as_index_labels:
- application
- environment
- kubernetes_node_name
- kubernetes_node_ip
- kubernetes_deployment_name
- kubernetes_statefulset_name
- kubernetes_namespace
# -- Enable tracing
tracing:
enabled: true

View File

@ -48,8 +48,9 @@ spec:
- context: log
statements:
- set(log.body["kubernetes"], log.attributes["kubernetes"])
- set(log.attributes["service"]["name"], log.attributes["context"]["app"])
- set(log.attributes["deployment"]["environment"], log.attributes["context"]["env"])
- set(resource.attributes["application"], log.attributes["context"]["app"])
- set(resource.attributes["environment"], log.attributes["context"]["env"])
- context
batch:
send_batch_size: 5
timeout: 10s