Excluding Containers in Datadog - DD_CONTAINER_EXCLUDE

Settings that remove containers from Datadog monitoring take effect at the stage where the Agent discovers containers, and no data is sent for containers excluded by the global settings. This article walks through the six variables such as DD_CONTAINER_EXCLUDE, how to write patterns, and the precedence in which annotations win, together with how to tell whether the settings took effect.

Skip Them Before the Agent Picks Them Up, or Discard Them After Ingestion

There are two layers at which you can remove containers from monitoring. One is a setting that drops a container from the targets at the stage where the Agent discovers it; neither the metrics nor the logs of that container are sent to Datadog. The other is an exclusion filter, which keeps logs out of an index after they arrive, and that happens after ingestion. By default the Agent discovers every container on the host, and when you enable Helm's datadog.logs.containerCollectAll, it collects logs from every container it discovers. A container excluded from metrics collection is also removed from the targets of integrations attached by Autodiscovery (as of October 2026; source: Container Discovery Management). There are two ways to exclude: Agent environment variables that apply to the whole cluster, and annotations attached to each Pod.

The Six Variables Combine "Which Data" with "Exclude or Include"

The target is split three ways, by whether you exclude both metrics and logs or only one of them, and two ways, by whether you specify what to exclude (a blocklist) or what to include (an allowlist), so the combinations give six environment variables. All of them are available in Agent v7.20 and later, and the Helm chart provides the same six as keys under datadog..

Variables and keys used to filter containers (as of October 2026)
What to exclude / keepExclude (environment variable)Include (environment variable)Helm key (exclude / include)
Both metrics and logsDD_CONTAINER_EXCLUDEDD_CONTAINER_INCLUDEdatadog.containerExclude / datadog.containerInclude
Metrics onlyDD_CONTAINER_EXCLUDE_METRICSDD_CONTAINER_INCLUDE_METRICSdatadog.containerExcludeMetrics / datadog.containerIncludeMetrics
Logs onlyDD_CONTAINER_EXCLUDE_LOGSDD_CONTAINER_INCLUDE_LOGSdatadog.containerExcludeLogs / datadog.containerIncludeLogs
Source: Container Discovery Management

With the Datadog Operator, you list them as environment variables under spec.override.nodeAgent.env, and with a containerized Agent that uses neither the Operator nor Helm, you pass them at startup with docker run -e. In Helm, the value is a single string with multiple patterns separated by spaces.

datadog:
  containerExcludeLogs: "kube_namespace:^batch-jobs$"
  containerExclude: "name:^log-shipper$"

The first line removes only the logs of containers in the batch-jobs namespace and keeps their metrics. The second line removes the container named log-shipper from both metrics and logs. The namespace and name here are illustrative values; replace them with the names in your own environment.

A Pattern Is a Regular Expression Prefixed with name / image / kube_namespace

Each value is a regular expression prefixed with one of name:image:kube_namespace:, and when you list several, you separate them with spaces. What name matches against is the container name, and even on Kubernetes it does not match the Pod name. image is matched against the full image name, from the registry through the tag and digest, so image:agent, which anchors neither end, picks up every image that contains agent anywhere in its name. To exclude a single image regardless of tag, anchor the start with ^ and allow a tag and digest after the name. Even when excluding every container, you need the prefix word, as in name:.*; writing .* alone has no effect (as of October 2026; source: Container Discovery Management).

Include Wins over Exclude, and Pod Exclusion Annotations Rank Higher Still

When an exclude setting and an include setting both match the same container, the include setting wins as a rule. If you want to monitor only specific images, you put image:.* in DD_CONTAINER_EXCLUDE to remove everything and write the images to keep in DD_CONTAINER_INCLUDE. What to watch out for is that the global settings and the logs / metrics-specific settings do not act on each other. You cannot bring back a container excluded by the global setting with DD_CONTAINER_INCLUDE_LOGS. If you exclude only the metrics of one image and keep another image, write the include side as two settings as well, one for metrics and one for logs.

Exclusion annotations attached to a Pod (Agent v7.45 and later; value "true"; as of October 2026)
AnnotationWhat is excluded
ad.datadoghq.com/excludeThe entire Pod
ad.datadoghq.com/logs_excludeLog collection for the entire Pod
ad.datadoghq.com/metrics_excludeMetrics collection for the entire Pod
ad.datadoghq.com/<CONTAINER_NAME>.excludeThe specified container in the Pod
ad.datadoghq.com/<CONTAINER_NAME>.logs_excludeLog collection for the specified container
ad.datadoghq.com/<CONTAINER_NAME>.metrics_excludeMetrics collection for the specified container
Source: Container Discovery Management (Pod exclude configuration)

These annotations are what the official documentation names as the exception to the rule that include wins. Containers in a Pod whose ad.datadoghq.com/exclude is set to "true" are not monitored even if they match DD_CONTAINER_INCLUDE, and the annotations for logs and for metrics are treated the same way. For example, when collecting logs from a container named helper, the Agent checks four annotations: exclusion of the entire Pod, log exclusion for the entire Pod, exclusion of helper, and log exclusion for helper. If the people who write the variables and the people who write the Deployment are on different teams, then for a container that does not show up even though the variables include it, the first thing to suspect is the Pod annotations.

Counts That Do Not Drop When You Exclude, and Containers Excluded from the Start

Right after adding a filter, you will want to look at the container count graph. However, running counts such as kubernetes.containers.running and docker.containers.running are not affected by this setting and keep counting every container. A graph that does not go down is not evidence that the setting is not working; judge whether it took effect by whether the excluded container's own metrics, such as CPU, and its logs have stopped arriving. Conversely, some containers are excluded from the targets even if you write nothing.

Things treated separately from the six variables (as of October 2026)
TargetDefault handlingSetting that changes the handling
Running and stopped count metrics (kubernetes.containers.running / kubernetes.pods.running / docker.containers.running and .stopped / .running.total / .stopped.total)Count every container regardless of filtering-
Kubernetes and OpenShift pause containersExcluded by default (included in the running count metrics)Set DD_EXCLUDE_PAUSE_CONTAINER to false / Helm's datadog.excludePauseContainer
Pods that are not ready (unready)Not checked, so no metrics / service checks / logs are collectedSet the Pod annotation ad.datadoghq.com/tolerate-unready to "true"
Security products (Cloud Security misconfigurations and vulnerabilities / Workload Protection)Filtered by variables separate from the six above (Agent v7.70 and later)DD_COMPLIANCE_CONFIG_CONTAINER_EXCLUDE, DD_SBOM_CONTAINER_IMAGE_CONTAINER_EXCLUDE, and others
Source: Container Discovery Management / Containers Billing

A pause container is a container that Kubernetes creates to obtain the Pod's IP address and set up the network namespace. Datadog does not include it among the containers counted for billing (excluding Amazon EKS pause containers requires Agent v7.20 or later). The variable that stops the default exclusion is for when you want to see even the metrics of pause containers. The filters for security products are variables provided so that you are billed only for the containers you want to monitor. The overall picture of how billing is counted is summarized in the overview of pricing.

To Use Pod Names or Annotations as Conditions, Write a CEL Expression

For conditions that a regular expression cannot express, use cel_workload_exclude, introduced in Agent v7.73. It combines container name, image reference, Pod name, namespace, and annotations in a Common Expression Language (CEL) expression. For each set of rules, products decides what to exclude from, metrics / logs / global, and a container is excluded if it matches even one of the rules. If the configuration structure or an expression contains an error, the Agent exits with an error to prevent unintended collection from affecting billing. Before rolling it out, pass it to agent workloadfilter verify-cel on standard input to check the syntax. For the containerized Agent, write it as JSON in DD_CEL_WORKLOAD_EXCLUDE. The Helm value is datadog.celWorkloadExclude (as of October 2026; source: Container Discovery Management).

Choosing the Setting by the Reason for Excluding

The setting to use changes depending on whether the reason for excluding is the volume of logs, the number of metrics, or that monitoring itself is unnecessary. List the containers in the cluster by namespace and image, match each reason to the left column of the table below, and that determines which variable or annotation to use.

Reasons for excluding and the setting to use (as of October 2026)
Reason for excludingSetting to useHow to target
Reduce only the volume of logsDD_CONTAINER_EXCLUDE_LOGSName / image / namespace pattern
Exclude only metricsDD_CONTAINER_EXCLUDE_METRICSName / image / namespace pattern
Monitoring itself is not neededDD_CONTAINER_EXCLUDEExclude both metrics and logs
Exclude only specific PodsPod annotation ad.datadoghq.com/exclude (logs_exclude for logs only)Set "true" on each Pod
Use Pod names or annotations as conditionscel_workload_exclude (Agent v7.73 and later)CEL expression
Source: Container Discovery Management

Where to put the values follows the steps in installing with Helm for Helm and the Operator, and in installing with Docker for standalone Docker. After the change is applied, search the Log Management and Container Monitoring screens by the name of a container you should have excluded; if the type of data you excluded does not appear, the setting is working.

References

Share