License your Kubernetes workloads per container-hour with Container Application Monitoring. This works with OneAgent and OpenTelemetry on all supported distributions, with or without Dynatrace Operator.
k8s.pod.uid and k8s.container.name to telemetry from the containers it injects. Without the Operator, you set them yourself.| Aspect | With Dynatrace Operator | Without Dynatrace Operator |
|---|---|---|
| Container identity attributes | Added automatically, except for sidecar containers | You set them in OTEL_RESOURCE_ATTRIBUTES |
| Opt-in | Tenant-wide setting (OneAgent), DynaKube, or pod annotation | Tenant-wide setting (OneAgent) or OTEL_RESOURCE_ATTRIBUTES |
| Setup guide | Kubernetes setup with Dynatrace Operator | Without Dynatrace Operator |
With OneAgent injection, Dynatrace Operator adds the container identity attributes only to the containers it injects. Sidecar containers in the same pod don't get them. To make an instrumented sidecar eligible, either use OTLP exporter auto-configuration, which covers sidecars too, or set the attributes yourself.
OneAgent version 1.345+
All options require OneAgent version 1.345+. Use one of these options:
Tenant-wide setting: Enable builtin:billing.container-application-monitoring.optin to opt in all eligible OneAgent containers at once. A container is eligible if its telemetry carries the container identity attributes. The setting is enabled by default for new customers and takes effect without a restart. Once you enable it, you can't disable it.
Per DynaKube: Add the attribute under spec.resourceAttributes to opt in all components:
spec:resourceAttributes:dt.has_container_application_monitoring: "true"
To opt in only OneAgent, add it under spec.oneAgent.applicationMonitoring.additionalResourceAttributes instead:
spec:oneAgent:applicationMonitoring:additionalResourceAttributes:dt.has_container_application_monitoring: "true"
For OpenTelemetry only, use spec.otlpExporterConfiguration.additionalResourceAttributes. If you set the same key in both places, the per-component value overrides spec.resourceAttributes.
Per workload: Add the annotation to the pod template:
spec:template:metadata:annotations:metadata.dynatrace.com/dt.has_container_application_monitoring: "true"
Without the Operator, add dt.has_container_application_monitoring=true to OTEL_RESOURCE_ATTRIBUTES instead, together with the container identity attributes. See Without Dynatrace Operator.
The resource attribute options are reversible: remove the attribute and restart the workloads.
The tenant-wide setting applies to OneAgent only. OpenTelemetry workloads are licensed as Container Application Monitoring only if their telemetry carries dt.has_container_application_monitoring=true.
Enable OTLP exporter auto-configuration and add the opt-in. The Operator injects the endpoint, token, and container identity attributes into pods in the selected namespaces. Without a namespace selector, it configures and opts in pods in all namespaces:
spec:otlpExporterConfiguration:signals:traces: {}metrics: {}additionalResourceAttributes:dt.has_container_application_monitoring: "true"namespaceSelector: # Optional. Limits the opt-in to these namespaces.matchLabels:container_application_monitoring-otlp: "true" # Adjust to target your namespaces.
Set the opt-in and the container identity attributes in OTEL_RESOURCE_ATTRIBUTES on each application container. Get the pod UID from the Kubernetes Downward API, and set the container name to the name in your pod spec:
spec:containers:- name: checkoutenv:- name: K8S_POD_UIDvalueFrom:fieldRef:fieldPath: metadata.uid- name: OTEL_RESOURCE_ATTRIBUTESvalue: "dt.has_container_application_monitoring=true,k8s.pod.uid=$(K8S_POD_UID),k8s.container.name=checkout"
Define K8S_POD_UID before OTEL_RESOURCE_ATTRIBUTES, so Kubernetes can expand it. This also works for OneAgent without the Operator. If the tenant-wide setting covers the workload, leave out the opt-in attribute.
If you route telemetry through an OpenTelemetry Collector, make sure it keeps these resource attributes.
Without k8s.pod.uid and k8s.container.name, Dynatrace can't attribute OpenTelemetry telemetry to a container. That telemetry is licensed as Traces and Metrics - Ingest & Process instead.
Resource attributes are injected when a pod starts. After you change the DynaKube, an annotation, or OTEL_RESOURCE_ATTRIBUTES, restart the affected workloads:
kubectl rollout restart deployment -n <namespace>
The tenant-wide setting needs no restart.
In Account Management, go to Subscription > Overview > Cost and usage details, select Container Application Monitoring, and check that consumption increases. You can also query billing usage events, as described in Migrate to Container Application Monitoring.