Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/elasticsearch] Add ecs mapping for k8s.deployment.name (#33622
) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This PR adds a mapping for the `k8s.deployment.name` attribute which is enabled by default by the [`k8sattributesprocessor`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/721c9e68de27d00a5ce0651f4b2f47761547e296/processor/k8sattributesprocessor/metadata.yaml#L37-L40). The idea is to have all the enabled by default attributes mapped to ECS properly, for consistency. **Link to tracking Issue:** <Issue number if applicable> ~ **Testing:** <Describe what testing was performed and which tests were added.> Tested locally with: ```yaml mode: daemonset presets: logsCollection: enabled: true storeCheckpoints: true kubernetesAttributes: enabled: true extraEnvs: - name: ES_ENDPOINT valueFrom: secretKeyRef: name: elastic-secret key: es_endpoint - name: ES_API_KEY valueFrom: secretKeyRef: name: elastic-secret key: es_api_key image: repository: otelcontribcol-dev tag: "0.0.1" pullPolicy: IfNotPresent command: name: otelcontribcol config: exporters: debug: verbosity: detailed elasticsearch/logs: endpoints: - ${env:ES_ENDPOINT} api_key: ${env:ES_API_KEY} logs_index: otel_logs_index mapping: mode: ecs sending_queue: enabled: true num_consumers: 20 queue_size: 1000 receivers: filelog: start_at: end include_file_name: false include_file_path: true exclude: - /var/log/pods/default_daemonset-opentelemetry-collector*_*/opentelemetry-collector/*.log include: - /var/log/pods/*/*/*.log operators: - id: container-parser type: container output: some processors: k8sattributes: filter: node_from_env_var: K8S_NODE_NAME passthrough: false pod_association: - sources: - from: resource_attribute name: k8s.pod.ip - sources: - from: resource_attribute name: k8s.pod.uid - sources: - from: connection extract: metadata: - "k8s.namespace.name" - "k8s.deployment.name" - "k8s.node.name" - "k8s.pod.name" - "k8s.pod.uid" service: pipelines: logs: receivers: [filelog] processors: [batch] exporters: [elasticsearch/logs] ``` The documents are stored in ES properly: ```json { "@timestamp": "2024-06-18T10:57:45.307790375Z", "agent": { "name": "otlp" }, "k8s": { "container": { "name": "busybox", "restart_count": "0" }, }, "kubernetes": { "deployment": { "name": "deploy-logs" }, "namespace": { "name": "default" }, "node": { "name": "kind-control-plane" }, "pod": { "name": "deploy-logs-595cdc6b8b-dptrr", "uid": "5166a2e2-9152-4d86-b8a4-668cc2f49a39" } }, "log": { "file": { "path": "/var/log/pods/default_deploy-logs-595cdc6b8b-dptrr_5166a2e2-9152-4d86-b8a4-668cc2f49a39/busybox/0.log" }, "iostream": "stdout" }, "logtag": "F", "message": "otel logs at 10:57:45", "time": "2024-06-18T10:57:45.307790375Z" } ``` **Documentation:** <Describe the documentation added.> ~ /cc @carsonip @lahsivjar @andrzej-stencel --------- Signed-off-by: ChrsMark <[email protected]>
- Loading branch information