The Datadog Agent can create and assign tags to all metrics, traces, and logs emitted by a container based on its labels or environment variables.
If you are running the Agent as a binary on a host, configure your tag extractions with the Agent tab instructions. If you are running the Agent as a container, configure your tag extraction with the Containerized Agent tab instructions.
The Agent can Autodiscover and attach tags to all data emitted by containers. The list of tags attached depends on the Agent cardinality configuration.
Tag
Cardinality
Requirement
container_name
High
N/A Note: not included for the containerd runtime.
container_id
High
N/A
rancher_container
High
Rancher environment
mesos_task
Orchestrator
Mesos environment
docker_image
Low
N/A Note: not included for the containerd runtime.
As a best practice in containerized environments, Datadog recommends using unified service tagging when assigning tags. Unified service tagging ties Datadog telemetry together through the use of three standard tags: env, service, and version. To learn how to configure your environment with unified tagging, see the dedicated unified service tagging documentation.
To extract a given container label <LABEL_NAME> and transform it as a tag key <TAG_KEY> within Datadog, add the following environment variable to the Datadog Agent:
Note: <LABEL_NAME> is not case-sensitive. For example, if you have labels named foo and FOO, and you set DD_CONTAINER_LABELS_AS_TAGS='{"foo": "bar"}', both foo and FOO are mapped to bar.
Note: DD_CONTAINER_LABELS_AS_TAGS is equivalent to the old DD_DOCKER_LABELS_AS_TAGS, and DD_CONTAINER_ENV_AS_TAGS to DD_DOCKER_ENV_AS_TAGS.
To extract a given container label <LABEL_NAME> and transform it as a tag key <TAG_KEY> within Datadog, add the following configuration block in the Agent datadog.yaml configuration file:
Starting with Agent v7.20+, a containerized Agent can Autodiscover tags from container labels. This process allows the Agent to associate custom tags to all data emitted by a container without modifying the Agent datadog.yaml file.
With Agent v6.0+, the Agent can collect environment variables for a given container and use them as tags to attach to all data emitted by this container.
To extract a given container environment variable <ENVVAR_NAME> and transform it as a tag key <TAG_KEY> within Datadog, add the following environment variable to the Datadog Agent:
To extract a given container environment variable <ENVVAR_NAME> and transform it as a tag key <TAG_KEY> within Datadog, add the following configuration block in the Agent datadog.yaml configuration file: