Skip to content

Commit 6cdb4fb

Browse files
committed
base cel docs
1 parent 499b0fe commit 6cdb4fb

File tree

1 file changed

+105
-3
lines changed

1 file changed

+105
-3
lines changed

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

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,111 @@ Set `DD_EXCLUDE_PAUSE_CONTAINER` to `false`.
253253

254254
## Advanced CEL exclusion
255255

256-
Use the parameters in the table below to configure filtering for container
256+
In **Agent v7.73+**, you can use the `cel_workload_exclude` configuration option to filter containers from Autodiscovery. This feature allows you to define [Common Expression Langauge][3] rules with fine granularity to target containers to be excluded from telemetry collection by product.
257257

258+
Use the defined parameters for the container representation in the table below to configure filtering rules:
258259

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+
| Attribute | Description |
261+
|-----------------------------|-------------------------------------------------------------------------|
262+
| `container.name` | The name of the container. |
263+
| `container.image.reference` | The full reference of the container image (registry, repo, tag/digest). |
264+
| `container.pod.name` | The name of the pod running the container. |
265+
| `container.pod.namespace` | The Kubernetes namespace of the pod. |
266+
| `container.pod.annotations` | The annotations applied to the pod (key-value map). |
267+
268+
### Configuration structure
269+
270+
The `cel_workload_exclude` configuration is structured as a list of rule sets joined by logical **ORs**. Each rule set defines the `products` to exclude and the corresponding CEL `rules` to match against containers.
271+
272+
The `products` field accepts `metrics`, `logs`, and `global` (exclude container from all listed products).
273+
274+
If the configuration contains typos or structural errors, the Agent process gracefully crashes to prevent collecting unintended telemetry which could impact billing. Additionally, the CEL compiler performs basic type checking to ensure valid operations on the container attributes.
275+
276+
In the example below, metrics and logs are excluded for any `nginx` container running in the `staging` namespace. Additionally, logs are excluded for any container running the `redis` image, **or** any container within a pod that has the annotation `low_priority: "true"`.
277+
278+
```yaml
279+
cel_workload_exclude:
280+
- products: [metrics, logs]
281+
rules:
282+
containers:
283+
- container.name.matches("nginx") && container.pod.namespace == "staging"
284+
- products: [logs]
285+
rules:
286+
containers:
287+
- container.image.reference.matches("redis")
288+
- container.pod.annotations["low_priority"] == "true"
289+
```
290+
291+
The CEL-backed workload exclusion can also be configured by providing a JSON environment value to `DD_CEL_WORKLOAD_EXCLUDE`.
292+
293+
{{% collapse-content title="Setting environment variables" level="h4" expanded=false id="setting-environment-variables" %}}
294+
295+
{{< tabs >}}
296+
{{% tab "Datadog Operator" %}}
297+
298+
In Datadog Operator, set these environment variables under `spec.override.nodeAgent.env`.
299+
300+
##### Example
301+
302+
```yaml
303+
apiVersion: datadoghq.com/v2alpha1
304+
kind: DatadogAgent
305+
metadata:
306+
name: datadog
307+
spec:
308+
global:
309+
credentials:
310+
apiKey: <DATADOG_API_KEY>
311+
override:
312+
nodeAgent:
313+
env:
314+
- name: DD_CEL_WORKLOAD_EXCLUDE
315+
value: '[{"products":["global"],"rules":{"containers":["container.name == \"redis\""]}}]'
316+
```
317+
318+
{{% /tab %}}
319+
{{% tab "Helm" %}}
320+
321+
In your Helm chart, use the `datadog.celWorkloadExclude` configuration option.
322+
323+
##### Example
324+
325+
```yaml
326+
datadog:
327+
celWorkloadExclude:
328+
- products: [global]
329+
rules:
330+
containers:
331+
- container.name == "redis"
332+
```
333+
334+
{{% /tab %}}
335+
{{% tab "Containerized Agent" %}}
336+
337+
In environments where you are not using Helm or the Operator, the following environment variables can be passed to the Agent container at startup.
338+
339+
##### Example Docker
340+
341+
```shell
342+
docker run -e DD_CEL_WORKLOAD_EXCLUDE=<JSON_CEL_RULES> ...
343+
```
344+
345+
##### Example ECS
346+
347+
```json
348+
"environment": [
349+
{
350+
"name": "DD_CEL_WORKLOAD_EXCLUDE",
351+
"value": "<JSON_CEL_RULES>"
352+
},
353+
...
354+
]
355+
```
356+
357+
{{% /tab %}}
358+
{{< /tabs >}}
359+
360+
{{% /collapse-content %}}
260361

261362
## Pod exclude configuration
262363

@@ -376,4 +477,5 @@ In environments where you are not using Helm or the Operator, the following envi
376477
{{< partial name="whats-next/whats-next.html" >}}
377478

378479
[1]: /containers/kubernetes/log/?tab=helm#log-collection
379-
[2]: /getting_started/containers/autodiscovery
480+
[2]: /getting_started/containers/autodiscovery
481+
[3]: https://github.com/google/cel-spec/blob/master/doc/langdef.md

0 commit comments

Comments
 (0)