By default, the Datadog Agent automatically discovers all containers available. This document describes how to restrict the Datadog Agent’s discovery perimeter and limit data collection to a subset of containers.
In a containerized environment, you should deploy the Datadog Agent once per host. Each Datadog Agent deployed automatically discovers and monitors all containers on its respective host.
You can adjust the discovery rules for the Agent to restrict metric and log collection. Any containers restricted from metric collection are also restricted for any Autodiscovery-based Agent integrations.
When the logs containerCollectAll option is enabled, the Agent collects logs from all discovered containers. These filtering options do not affect log collection if containerCollectAll is not enabled.
You can set exceptions in two ways:
Provide environment variables to the Datadog Agent container as an allowlist/blocklist of containers. Recommended if you have a list of container names, images, or namespaces to exclude for the entire cluster.
Add annotations to your Kubernetes pods to block individual pods or containers. Recommended if you need fine-tuned exclusions.
Note: The kubernetes.containers.running, kubernetes.pods.running, docker.containers.running, .stopped, .running.total, and .stopped.total metrics are not affected by these settings and always count all containers.
Use the environment variables in the table below to configure container filtering. Each inclusion or exclusion is defined as a list of space-separated regex strings. You can include or exclude containers based on their container name (name), image name (image), or Kubernetes namespace (kube_namespace).
In Agent v7.20+, use the following environment variables to exclude containers by image name, container name, or Kubernetes namespace. Logs and metrics are not collected from excluded containers.
Environment variable
Description
DD_CONTAINER_EXCLUDE
Blocklist of containers to exclude.
DD_CONTAINER_EXCLUDE_METRICS
Blocklist of containers whose metrics are excluded.
DD_CONTAINER_EXCLUDE_LOGS
Blocklist of containers whose logs are excluded.
DD_CONTAINER_INCLUDE
Allowlist of containers to include.
DD_CONTAINER_INCLUDE_METRICS
Allowlist of containers whose metrics are included.
DD_CONTAINER_INCLUDE_LOGS
Allowlist of containers whose logs are included.
In Agent <=v7.19, use the environment variables DD_AC_INCLUDE and DD_AC_EXCLUDE to include or exclude a container by image or name. These environment variables are deprecated in later Agent versions.
Image name filters (image) are matched across full image name, including the registry and the image tag or digest (for example, dockerhub.io/nginx:1.13.1).
Inclusion takes precedence over exclusion. For example, to only monitor ubuntu or debian images, first exclude all other images and then specify which images to include:
You cannot mix cross-category inclusion/exclusion rules. For instance, if you want to include a container with the image name foo and exclude only metrics from a container with the image name bar, the following is not sufficient:
There is no interaction between the global lists and the selective (logs and metrics) lists. In other words, you cannot exclude a container globally (DD_CONTAINER_EXCLUDE) and then include it with DD_CONTAINER_INCLUDE_LOGS and DD_CONTAINER_INCLUDE_METRICS.
In your Helm chart, supply a space-separated string to datadog.containerExclude, datadog.containerInclude, datadog.containerExcludeLogs, datadog.containerIncludeLogs, datadog.containerExcludeMetrics, or datadog.containerIncludeMetrics.
The Datadog Agent excludes Kubernetes and OpenShift pause containers by default. This prevents their metric collection and counting as billable containers. They are still counted in the container count metrics such as kubernetes.containers.running and docker.containers.running.
To disable this behavior and include monitoring the pause containers:
In Agent v7.45+ you can set annotations on your Kubernetes pods to control Autodiscovery. Set the following annotations with the value "true" to add exclusion rules.
Annotation
Description
ad.datadoghq.com/exclude
Excludes the entire pod
ad.datadoghq.com/logs_exclude
Excludes log collection from the entire pod
ad.datadoghq.com/metrics_exclude
Excludes metric collection from the entire pod
ad.datadoghq.com/<CONTAINER_NAME>.exclude
Excludes the container with <CONTAINER_NAME> in the pod
ad.datadoghq.com/<CONTAINER_NAME>.logs_exclude
Excludes log collection from the container with <CONTAINER_NAME> in the pod
ad.datadoghq.com/<CONTAINER_NAME>.metrics_exclude
Excludes metric collection from the container with <CONTAINER_NAME> in the pod
By default, unready pods are ignored when the Datadog Agent schedules checks. Therefore, metrics, service checks, and logs are not collected from these pods. To override this behavior, set the annotation ad.datadoghq.com/tolerate-unready to "true". For example: