Your pods send OpenTelemetry traces, but in Dynatrace they arrive with no pod name, no namespace and no node. You cannot tie a latency spike to a specific deployment, and MTTR grows. Deploying an OpenTelemetry Collector Kubernetes DaemonSet, enriched by the k8sattributes processor, fixes this at the source.
Goal of this tutorial: install a Collector in the cluster with Helm (or with the OpenTelemetry Operator), add Kubernetes metadata to every span, metric and log, then export everything over OTLP to Dynatrace. The content applies to both Dynatrace SaaS and Dynatrace Managed; only the ingest URL changes.
If the Collector is new to you, start with the OpenTelemetry Collector for Dynatrace, which explains the receivers → processors → exporters pipeline outside Kubernetes.
Prerequisites
- A Kubernetes 1.26 or later cluster,
kubectland Helm 3. - A Dynatrace API token with the
openTelemetryTrace.ingest,metrics.ingestandlogs.ingestscopes. - The OTLP URL of your environment:
- SaaS:
https://<env-id>.live.dynatrace.com/api/v2/otlp; - Managed:
https://<your-domain>/e/<env-id>/api/v2/otlp(or through an environment ActiveGate).
- SaaS:
- Applications already instrumented with an OpenTelemetry SDK or agent (for example the OpenTelemetry Java agent).
Which deployment mode should you choose?
- DaemonSet: one Collector per node. Pods send their telemetry to the local Collector. This is the recommended mode for
k8sattributes, because each Collector only watches the pods on its own node. - Deployment: a pool of Collectors behind a Service. Useful as a central gateway, for example for sampling.
- Dynatrace Operator: it manages OneAgent and ActiveGate. Do not confuse it with the OpenTelemetry Operator, which manages Collectors and auto-instrumentation. Both can run in the same cluster.
This tutorial uses a DaemonSet. If OneAgent also runs in the cluster, read how to avoid duplicate spans before enabling both.
Install the OpenTelemetry Collector Kubernetes DaemonSet with Helm
Step 1: create the namespace and the secret
kubectl create namespace observability kubectl -n observability create secret generic dynatrace-otlp \ --from-literal=DT_ENDPOINT='https://<env-id>.live.dynatrace.com/api/v2/otlp' \ --from-literal=DT_API_TOKEN='dt0c01.XXXX' The token stays in a Secret, never in the versioned values file.
Step 2: write the values.yaml file
mode: daemonset image: repository: otel/opentelemetry-collector-contrib command: name: otelcol-contrib presets: kubernetesAttributes: enabled: true # adds k8sattributes + RBAC extractAllPodLabels: false extraEnvsFrom: - secretRef: name: dynatrace-otlp config: receivers: otlp: protocols: grpc: endpoint: ${env:MY_POD_IP}:4317 http: endpoint: ${env:MY_POD_IP}:4318 processors: memory_limiter: check_interval: 1s limit_percentage: 80 spike_limit_percentage: 25 cumulative_to_delta: {} batch: send_batch_size: 1000 timeout: 5s exporters: otlphttp/dynatrace: endpoint: ${env:DT_ENDPOINT} headers: Authorization: "Api-Token ${env:DT_API_TOKEN}" service: pipelines: traces: receivers: [otlp] processors: [memory_limiter, k8s_attributes, batch] exporters: [otlphttp/dynatrace] metrics: receivers: [otlp] processors: [memory_limiter, k8s_attributes, cumulative_to_delta, batch] exporters: [otlphttp/dynatrace] logs: receivers: [otlp] processors: [memory_limiter, k8s_attributes, batch] exporters: [otlphttp/dynatrace] The critical lines:
-
image.repository: the contrib image containsk8sattributesandcumulative_to_delta. Dynatrace also publishes its own Collector distribution; check on docs.dynatrace.com which image and components it includes. -
presets.kubernetesAttributes: the chart adds the processor and creates the ClusterRole that lets it read pods, namespaces and ReplicaSets. -
cumulative_to_delta: Dynatrace expects OTLP metrics with delta temporality. Details are in OTLP metric temporality. -
memory_limiterfirst: it protects the node if Dynatrace slows down.
In recent Collector contrib versions, the k8sattributes processor is named k8s_attributes (and cumulativetodelta becomes cumulative_to_delta); the old names remain accepted as deprecated aliases. The chart, which rewrites those old names by default (rewriteDeprecatedComponentNames), places k8s_attributes in the pipelines itself with the preset; writing it explicitly, as here, makes the order visible. If the chart reports a duplicate in your version, remove it from the list.
Step 3: install the chart
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts helm repo update helm upgrade --install otel-node open-telemetry/opentelemetry-collector \ -n observability -f values.yaml Step 4: point applications to the node’s Collector
Each application pod sends its telemetry to its node IP, using the Downward API:
env: - name: NODE_IP valueFrom: fieldRef: fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_ENDPOINT value: "http://$(NODE_IP):4318" - name: OTEL_EXPORTER_OTLP_PROTOCOL value: "http/protobuf" Depending on the chart version, host port 4318 is exposed by default in DaemonSet mode; check the ports section of your values. Otherwise, use the Service the chart creates.
Alternative: the OpenTelemetry Operator
The Operator declares the Collector as a Kubernetes resource. Its webhooks need a TLS certificate: cert-manager by default, or a self-signed certificate generated by the Helm chart (admissionWebhooks.autoGenerateCert). Once installed (chart open-telemetry/opentelemetry-operator), the same configuration looks like this:
apiVersion: opentelemetry.io/v1beta1 kind: OpenTelemetryCollector metadata: name: otel-node namespace: observability spec: mode: daemonset image: otel/opentelemetry-collector-contrib:latest envFrom: - secretRef: name: dynatrace-otlp config: receivers: otlp: protocols: grpc: {} http: {} processors: k8s_attributes: auth_type: serviceAccount filter: node_from_env_var: K8S_NODE_NAME extract: metadata: - k8s.namespace.name - k8s.pod.name - k8s.deployment.name - k8s.node.name pod_association: - sources: - from: connection batch: {} exporters: otlphttp/dynatrace: endpoint: ${env:DT_ENDPOINT} headers: Authorization: "Api-Token ${env:DT_API_TOKEN}" service: pipelines: traces: receivers: [otlp] processors: [k8s_attributes, batch] exporters: [otlphttp/dynatrace] Here you handle three things yourself that the Helm preset did: the K8S_NODE_NAME variable (injected through the Downward API spec.nodeName), the ClusterRole and its binding to the Collector’s ServiceAccount. In production, pin a precise image version rather than latest.
How to check that it works
-
The DaemonSet pods are running, one per node:
kubectl -n observability get pods -o wide kubectl -n observability logs ds/otel-node-opentelemetry-collector | grep -iE "error|refused|401|403"A
401or403points to the token or its scopes; aforbiddenerror on pods points to thek8sattributesRBAC. -
On SaaS, open a Notebook and run:
fetch spans, from: now() - 30m | filter isNotNull(k8s.pod.name) | summarize spans = count(), by: {k8s.namespace.name, k8s.deployment.name} | sort spans descIf the query returns nothing while spans exist, the Kubernetes attributes are missing: review
pod_association. On Managed, open the distributed traces view, select a trace and check that the
k8s.*attributes appear on the resource. Depending on the version, some attributes must be allowed in the OpenTelemetry attribute capture settings: see the documentation for your version.
If nothing arrives at all, follow the method in troubleshooting missing OpenTelemetry traces.
Best practices
- Set resource limits on the DaemonSet (
resources.limits.memory) and alignmemory_limiterwith them. - Extract only useful labels: every attribute adds volume and ingest cost.
- Separate roles: DaemonSet for enrichment, gateway Deployment for sampling (see OpenTelemetry tail sampling).
- Monitor the Collector itself: its internal metrics (export queue, refused data) are your first pipeline SLI.
- Version values.yaml and deploy it with GitOps to reduce toil.
Frequently asked questions
Do you need a Collector if OneAgent is already deployed?
Not necessarily. OneAgent can capture OpenTelemetry spans from some runtimes. The Collector becomes useful for workloads without OneAgent, for filtering or enrichment, or for a 100% OpenTelemetry strategy.
DaemonSet or sidecar?
The DaemonSet uses fewer resources and is managed in one place. The sidecar isolates each application but multiplies Collectors. Start with the DaemonSet.
Do container logs go through this Collector?
Only those sent over OTLP. To read container log files, you need the filelog receiver (the chart’s logsCollection preset); that is the subject of the article on OpenTelemetry logs.
Conclusion
An OpenTelemetry Collector on Kubernetes as a DaemonSet, with k8sattributes, turns anonymous spans into data tied to a pod, a deployment and a node. Diagnosis gets faster and your SLOs can be split by service. Start with a test namespace, validate the DQL query, then roll it out.
span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of Dynatrace LLC. Option and chart names change: check them in the official Dynatrace and OpenTelemetry documentation.
Originally published on span.observer. French version: https://span.observer/fr/collector-opentelemetry-kubernetes-dynatrace/.

