fix(opentelemetry): refine log processing by removing unnecessary fields and enhancing attribute insertion

Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
zhenyus 2025-04-21 15:05:05 +08:00
parent 90b4b3bb9b
commit 544293f7b2

View File

@ -26,11 +26,11 @@ spec:
include_file_name: false include_file_name: false
operators: operators:
- type: json_parser - type: json_parser
- type: remove parse_from: body
field: body parse_to: attributes
processors: processors:
k8sattributes: k8sattributes:
auth_type: "serviceAccount" auth_type: serviceAccount
wait_for_metadata: true wait_for_metadata: true
wait_for_metadata_timeout: 10s wait_for_metadata_timeout: 10s
passthrough: false passthrough: false
@ -43,27 +43,29 @@ spec:
- k8s.deployment.uid - k8s.deployment.uid
- k8s.namespace.name - k8s.namespace.name
- k8s.node.name - k8s.node.name
pod_association: attributes/k8s:
- sources: actions:
- from: resource_attribute - action: insert
name: k8s.pod.ip key: kubernetes.pod_name
- sources: from_attribute: k8s.pod.name
- from: resource_attribute - action: insert
name: k8s.pod.uid key: kubernetes.pod_ip
- sources: from_attribute: k8s.pod.ip
- from: connection - action: insert
resource: key: kubernetes.pod_uid
attributes: from_attribute: k8s.pod.uid
- key: loki.format - action: insert
action: insert key: kubernetes.deployment_name
value: json from_attribute: k8s.deployment.name
transform: - action: insert
log_statements: key: kubernetes.deployment_uid
- context: log from_attribute: k8s.deployment.uid
statements: - action: insert
- set(body, body.attributes) key: kubernetes.namespace_name
- delete_key(body, "attributes") from_attribute: k8s.namespace.name
- delete_key(body, "resources") - action: insert
key: kubernetes.node_name
from_attribute: k8s.node.name
batch: batch:
send_batch_size: 1000 send_batch_size: 1000
timeout: 10s timeout: 10s
@ -73,12 +75,9 @@ spec:
tls: tls:
insecure: true insecure: true
service: service:
telemetry:
logs:
level: "info"
pipelines: pipelines:
logs: logs:
receivers: [filelog] receivers: [filelog]
processors: [k8sattributes, resource, transform, batch] processors: [k8sattributes, attributes/k8s, batch]
exporters: [loki] exporters: [loki]
{{- end }} {{- end }}