Skip to content

Commit 499b0fe

Browse files
committed
rebase refactor
1 parent 2fec70d commit 499b0fe

File tree

1 file changed

+85
-66
lines changed

1 file changed

+85
-66
lines changed

content/en/containers/guide/container-discovery-management.md

Lines changed: 85 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ By default, the Datadog Agent automatically discovers all containers available.
2121

2222
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.
2323

24-
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][2]-based Agent integrations.
24+
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][2]-based Agent integrations.
2525

2626
When the logs [`containerCollectAll` option][1] is enabled, the Agent collects logs from all discovered containers. These filtering options do not affect log collection if `containerCollectAll` is not enabled.
2727

@@ -32,9 +32,10 @@ You can set exceptions in two ways:
3232

3333
**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.
3434

35-
## Agent configuration
35+
## Simple pattern matching
3636

3737
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:
38+
3839
- container name (`name`)
3940
- container image name (`image`)
4041
- Kubernetes namespace (`kube_namespace`)
@@ -46,6 +47,7 @@ The `name` parameter only applies to container names, not pod names, even if the
4647
</div>
4748

4849
### Environment variables
50+
4951
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.
5052

5153
| Environment variable | Description |
@@ -57,7 +59,71 @@ In **Agent v7.20+**, use the following environment variables to exclude containe
5759
| `DD_CONTAINER_INCLUDE_METRICS` | Allowlist of containers whose metrics are included. |
5860
| `DD_CONTAINER_INCLUDE_LOGS` | Allowlist of containers whose logs are included. |
5961

60-
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.
62+
{{% collapse-content title="Setting environment variables" level="h4" expanded=false id="setting-environment-variables" %}}
63+
64+
{{< tabs >}}
65+
{{% tab "Datadog Operator" %}}
66+
67+
In Datadog Operator, set these environment variables under `spec.override.nodeAgent.env`.
68+
69+
##### Example
70+
71+
```yaml
72+
apiVersion: datadoghq.com/v2alpha1
73+
kind: DatadogAgent
74+
metadata:
75+
name: datadog
76+
spec:
77+
global:
78+
credentials:
79+
apiKey: <DATADOG_API_KEY>
80+
override:
81+
nodeAgent:
82+
env:
83+
- name: DD_CONTAINER_EXCLUDE
84+
value: "image:<IMAGE_NAME>"
85+
```
86+
87+
{{% /tab %}}
88+
{{% tab "Helm" %}}
89+
90+
In your Helm chart, supply a space-separated string to `datadog.containerExclude`, `datadog.containerInclude`, `datadog.containerExcludeLogs`, `datadog.containerIncludeLogs`, `datadog.containerExcludeMetrics`, or `datadog.containerIncludeMetrics`.
91+
92+
##### Example
93+
94+
```yaml
95+
datadog:
96+
containerExclude: "image:<IMAGE_NAME_1> image:<IMAGE_NAME_2>"
97+
containerInclude: "image:<IMAGE_NAME_3> image:<IMAGE_NAME_4>"
98+
```
99+
100+
{{% /tab %}}
101+
{{% tab "Containerized Agent" %}}
102+
103+
In environments where you are not using Helm or the Operator, the following environment variables can be passed to the Agent container at startup.
104+
105+
##### Example Docker
106+
107+
```shell
108+
docker run -e DD_CONTAINER_EXCLUDE=image:<IMAGE_NAME> ...
109+
```
110+
111+
##### Example ECS
112+
113+
```json
114+
"environment": [
115+
{
116+
"name": "DD_CONTAINER_EXCLUDE",
117+
"value": "image:<IMAGE_NAME>"
118+
},
119+
...
120+
]
121+
```
122+
123+
{{% /tab %}}
124+
{{< /tabs >}}
125+
126+
{{% /collapse-content %}}
61127

62128
<div class="alert alert-info">
63129

@@ -66,6 +132,7 @@ Image name filters (`image`) are matched across full image name, including the r
66132
</div>
67133

68134
#### Examples
135+
69136
To exclude the container with the name `dd-agent`:
70137

71138
```
@@ -132,67 +199,7 @@ DD_CONTAINER_INCLUDE_LOGS = "image:^docker.io/library/foo(@sha256)?:.*"
132199

133200
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`.
134201

135-
### Setting environment variables
136-
{{< tabs >}}
137-
{{% tab "Datadog Operator" %}}
138-
139-
In Datadog Operator, set these environment variables under `spec.override.nodeAgent.env`.
140-
141-
##### Example
142-
143-
```yaml
144-
apiVersion: datadoghq.com/v2alpha1
145-
kind: DatadogAgent
146-
metadata:
147-
name: datadog
148-
spec:
149-
global:
150-
credentials:
151-
apiKey: <DATADOG_API_KEY>
152-
override:
153-
nodeAgent:
154-
env:
155-
- name: DD_CONTAINER_EXCLUDE
156-
value: "image:<IMAGE_NAME>"
157-
```
158-
{{% /tab %}}
159-
{{% tab "Helm" %}}
160-
161-
In your Helm chart, supply a space-separated string to `datadog.containerExclude`, `datadog.containerInclude`, `datadog.containerExcludeLogs`, `datadog.containerIncludeLogs`, `datadog.containerExcludeMetrics`, or `datadog.containerIncludeMetrics`.
162-
163-
##### Example
164-
165-
```yaml
166-
datadog:
167-
containerExclude: "image:<IMAGE_NAME_1> image:<IMAGE_NAME_2>"
168-
containerInclude: "image:<IMAGE_NAME_3> image:<IMAGE_NAME_4>"
169-
```
170-
171-
{{% /tab %}}
172-
{{% tab "Containerized Agent" %}}
173-
174-
In environments where you are not using Helm or the Operator, the following environment variables can be passed to the Agent container at startup.
175-
176-
##### Example Docker
177-
```shell
178-
docker run -e DD_CONTAINER_EXCLUDE=image:<IMAGE_NAME> ...
179-
```
180-
181-
##### Example ECS
182-
```json
183-
"environment": [
184-
{
185-
"name": "DD_CONTAINER_EXCLUDE",
186-
"value": "image:<IMAGE_NAME>"
187-
},
188-
...
189-
]
190-
```
191-
192-
{{% /tab %}}
193-
{{< /tabs >}}
194-
195-
#### Pause containers
202+
### Pause containers
196203

197204
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`.
198205

@@ -220,6 +227,7 @@ spec:
220227
- name: DD_EXCLUDE_PAUSE_CONTAINER
221228
value: "false"
222229
```
230+
223231
{{% /tab %}}
224232
{{% tab "Helm" %}}
225233

@@ -243,6 +251,13 @@ Set `DD_EXCLUDE_PAUSE_CONTAINER` to `false`.
243251
{{% /tab %}}
244252
{{< /tabs >}}
245253

254+
## Advanced CEL exclusion
255+
256+
Use the parameters in the table below to configure filtering for container
257+
258+
259+
. Each inclusion or exclusion is defined as a list of space-separated regex strings. You can include or exclude containers based on their:
260+
246261
## Pod exclude configuration
247262

248263
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.
@@ -260,7 +275,8 @@ The `ad.datadoghq.com/exclude` annotation set on the application pod takes the h
260275

261276
When applying annotation-based exclusions, the Agent checks for all relevant exclusion annotations on the container. For example, when configuring logs for an NGINX container, the Agent will look for `ad.datadoghq.com/exclude`, `ad.datadoghq.com/logs_exclude`, `ad.datadoghq.com/nginx.exclude`, or `ad.datadoghq.com/nginx.logs_exclude` annotations to be `true` on the pod. The same applies for metrics.
262277

263-
#### Exclude the entire pod:
278+
#### Exclude the entire pod
279+
264280
```yaml
265281
apiVersion: apps/v1
266282
kind: Deployment
@@ -276,7 +292,8 @@ spec:
276292
#(...)
277293
```
278294

279-
#### Exclude log collection from a container:
295+
#### Exclude log collection from a container
296+
280297
```yaml
281298
apiVersion: apps/v1
282299
kind: Deployment
@@ -316,6 +333,7 @@ In **Agent v7.70+**, you can restrict security monitoring for specific container
316333

317334
{{< tabs >}}
318335
{{% tab "Helm" %}}
336+
319337
| Feature | Include container | Exclude container |
320338
|---------------------------------------|-----------------------------------------------------|-----------------------------------------------------|
321339
| [Cloud Security Misconfigurations][1] | `datadog.securityAgent.compliance.containerInclude` | `datadog.securityAgent.compliance.containerExclude` |
@@ -328,6 +346,7 @@ In **Agent v7.70+**, you can restrict security monitoring for specific container
328346
{{% /tab %}}
329347
{{% tab "Config file" %}}
330348
For [Cloud Security Vulnerabilities][1], you can use the following format in your config file to include or exclude containers:
349+
331350
```
332351
---
333352
sbom:

0 commit comments

Comments
 (0)