Infra Attributes Processor
The infra attributes processor extracts Kubernetes tags based on labels or annotations and assigns these tags as resource attributes on traces, metrics, and logs.
When telemetry is exported from the otel-agent, these infra attributes will be converted into Datadog tags and used as metadata in Container Monitoring.
Configuration
The infra attributes processor will be added automatically by the converter component. If you opted out of the converter, or you want to change the defaults, you are able to configure the processor as so:
processors:
infraattributes:
cardinality: 0
The infra attributes processor also needs to be included in the pipelines in order to take effect:
service:
pipelines:
traces:
receivers: [otlp]
processors: [infraattributes]
exporters: [datadog/connector, datadog]
metrics:
receivers: [otlp, datadog/connector]
processors: [infraattributes]
exporters: [datadog]
logs:
receivers: [otlp]
processors: [infraattributes]
exporters: [datadog]
Cardinality
The cardinality option sets the TagCardinality in the Datadog Agent tagger component. Possible values for this option include:
cardinality: 0 - LowCardinality: in the host count order of magnitude (default)
cardinality: 1 - OrchestratorCardinality: tags that change value for each pod or task
cardinality: 2 - HighCardinality: typically tags that change value for each web request, user agent, container, etc.
Expected Attributes
The infra attributes processor looks up the following resource attributes in order to extract Kubernetes Tags. These resource attributes can be set in your SDK or in your otel-agent collector configuration:
| Entity |
Resource Attributes |
| workloadmeta.KindContainer |
container.id |
| workloadmeta.KindContainerImageMetadata |
oci.manifest.digest |
| workloadmeta.KindECSTask |
aws.ecs.task.arn |
| workloadmeta.KindKubernetesDeployment |
k8s.deployment.name, k8s.namespace.name |
| workloadmeta.KindKubernetesMetadata |
k8s.namespace.name, k8s.node.name |
| workloadmeta.KindKubernetesPod |
k8s.pod.uid |
| workloadmeta.KindProcess |
process.pid |
Container ID detection
If the container.id resource attribute is not present on the input, the infra attributes processor will attempt to automatically
detect it. This follows the same logic as the Agent's native Origin detection, but using resource attributes as the data source.
The following methods are tried, in order from highest to lowest precedence:
| Resource attributes |
Detection method |
process.pid (int) |
Based on container's external PID |
datadog.container.cgroup_inode (int) |
Based on container's cgroup inode |
k8s.pod.uid (str) + k8s.container.name (str) |
Based on container's pod and name |
For the method based on the container name, the datadog.container.is_init (boolean) resource attribute may be set to true to
direct the processor's search towards init-containers rather than regular ones.
SDK Configuration
The expected resource attributes can be set by using the OTEL_RESOURCE_ATTRIBUTES environment variable. For example, this can be set in your Kubernetes deployment yaml:
env:
...
- name: OTEL_SERVICE_NAME
value: {{ include "calendar.fullname" . }}
- name: OTEL_K8S_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: OTEL_K8S_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: OTEL_K8S_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: OTEL_K8S_POD_ID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: OTEL_RESOURCE_ATTRIBUTES
value: >-
service.name=$(OTEL_SERVICE_NAME),
k8s.namespace.name=$(OTEL_K8S_NAMESPACE),
k8s.node.name=$(OTEL_K8S_NODE_NAME),
k8s.pod.name=$(OTEL_K8S_POD_NAME),
k8s.pod.uid=$(OTEL_K8S_POD_ID),
k8s.container.name={{ .Chart.Name }},
host.name=$(OTEL_K8S_NODE_NAME),
deployment.environment=$(OTEL_K8S_NAMESPACE)
When using OTel SDK auto-instrumentation, some SDKs automatically set container.id and process.pid, while others may require manual configuration..
Collector Configuration
The expected resource attributes can be set by configuring the Kubernetes attributes processor and resource detection processor. This is demonstrated in the k8s-values.yaml example:
mode: daemonset
presets:
kubernetesAttributes:
enabled: true
extraEnvs:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: OTEL_RESOURCE_ATTRIBUTES
value: "k8s.pod.ip=$(POD_IP)"
config:
processors:
k8sattributes:
passthrough: false
auth_type: "serviceAccount"
pod_association:
- sources:
- from: resource_attribute
name: k8s.pod.ip
extract:
metadata:
- k8s.pod.name
- k8s.pod.uid
- k8s.deployment.name
- k8s.node.name
- k8s.namespace.name
- k8s.pod.start_time
- k8s.replicaset.name
- k8s.replicaset.uid
- k8s.daemonset.name
- k8s.daemonset.uid
- k8s.job.name
- k8s.job.uid
- k8s.cronjob.name
- k8s.statefulset.name
- k8s.statefulset.uid
- container.image.name
- container.image.tag
- container.id
- k8s.container.name
- container.image.name
- container.image.tag
- container.id
labels:
- tag_name: kube_app_name
key: app.kubernetes.io/name
from: pod
- tag_name: kube_app_instance
key: app.kubernetes.io/instance
from: pod
- tag_name: kube_app_version
key: app.kubernetes.io/version
from: pod
- tag_name: kube_app_component
key: app.kubernetes.io/component
from: pod
- tag_name: kube_app_part_of
key: app.kubernetes.io/part-of
from: pod
- tag_name: kube_app_managed_by
key: app.kubernetes.io/managed-by
from: pod
resourcedetection:
detectors: [env, eks, ec2, system]
timeout: 2s
override: false
exporters:
datadog:
api:
site: ${env:DD_SITE}
key: ${env:DD_API_KEY}
traces:
trace_buffer: 500
sending_queue:
batch:
service:
pipelines:
metrics:
receivers: [otlp]
processors: [resourcedetection, k8sattributes]
exporters: [datadog]
traces:
receivers: [otlp]
processors: [resourcedetection, k8sattributes]
exporters: [datadog]
logs:
receivers: [otlp]
processors: [resourcedetection, k8sattributes]
exporters: [datadog]
For the full list of Kubernetes Tags added by the infra attributes processor, see comp/core/tagger/tags/tags.go.