---
title: Log Agent tags
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > Agent > Host Agent Log collection > Log Agent tags
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Log Agent tags

## Overview{% #overview %}

The Datadog Agent automatically adds certain tags to all logs it collects before sending them to Datadog. These tags are added **pre-ingestion**, and are included in the payload that gets delivered to Datadog. To remove selected tags before the Agent sends logs, see Filter tags before ingestion.

## Pre-ingestion processing{% #pre-ingestion-processing %}

Since these tags are added pre-ingestion, they:

- Are included in all log data delivered to Datadog
- Increase the overall size of your log data
- Are available for filtering, searching, and aggregation in the Log Explorer
- Can be used in log-based metrics and queries

## Agent tags automatically added to logs{% #agent-tags-automatically-added-to-logs %}

The following tags are automatically added to logs by the Datadog Agent:

| Tag               | Description                                                          | Conditions                                                 |
| ----------------- | -------------------------------------------------------------------- | ---------------------------------------------------------- |
| `source`          | The source of the log (file path, integration name, etc.)            | Always when available                                      |
| `service`         | The service name if configured in the log collection                 | Always when available                                      |
| `env`             | The environment tag if configured globally                           | Always when available                                      |
| `version`         | The Agent version                                                    | Always when available                                      |
| `filename`        | Base name of the tailed file                                         | File-based sources only                                    |
| `dirname`         | Directory containing the tailed file                                 | File-based sources only                                    |
| `source_host`     | IP address of the socket source host                                 | Socket sources (TCP/UDP) only                              |
| `event_type`      | Type of the Windows event                                            | Windows events only                                        |
| `event_source`    | Source of the Windows event                                          | Windows events only                                        |
| `event_id`        | Windows Event ID                                                     | Windows events only, if `tag_event_id: true`               |
| `sid`             | Windows Security identifier                                          | Windows events only, if `tag_sid: true`                    |
| `truncated`       | Source of truncation                                                 | If `logs_config.tag_truncated_logs: true`                  |
| `multiline`       | Source of multi-line aggregation                                     | If `logs_config.tag_multi_line_logs: true`                 |
| `aggregated_json` | Indicates that the log was aggregated from multiple JSON log entries | If `logs_config.auto_multi_line.tag_aggregated_json: true` |

## Filter tags before ingestion{% #filter-tags-before-ingestion %}

Log tag filtering requires Agent 7.86.0 or later. Depending on how you use your logs, some Agent-added tags might not be needed for search, analysis, routing, or correlation. You can filter selected tags before the Agent sends logs to Datadog, which can help reduce the size of log payloads.

Choose the filter scope based on where you want the rule to apply:

- Use a global filter to apply the same rules to every supported log source processed by the Agent.
- Use a per-source filter to target one log source or create an exception to a global filter.

Tag filters apply to logs collected by the Agent's logs pipeline. They don't apply to logs from serverless-init, OTLP ingestion, or the Datadog Distribution of OpenTelemetry (DDOT) Collector.

Before you filter a tag, check whether any pipelines, indexes, archives, monitors, dashboards, or other workflows use it.

### Filter pattern syntax{% #filter-pattern-syntax %}

Patterns use `key:value` syntax. Keys must match exactly, values can contain `*` wildcards, and matching is not case-sensitive. An `include` pattern only preserves tags that an `exclude` pattern would otherwise remove. It doesn't remove any other tags.

**Note**: The Agent sends `source`, `service`, and `host` separately from the tag list. Filtering these tags does not remove their values from the log.

### Global filters{% #global-filters %}

Configure global filters in `datadog.yaml` or with the `DD_LOGS_CONFIG_TAG_FILTERS` environment variable. The following examples remove all `filename` and `dirname` tags except the `filename:audit.log` tag from every supported log source:

{% tab title="Configuration file" %}

```yaml
logs_config:
  tag_filters:
    exclude:
      - "filename:*"
      - "dirname:*"
    include:
      - "filename:audit.log"
```

{% /tab %}

{% tab title="Docker" %}
Pass `DD_LOGS_CONFIG_TAG_FILTERS` to the Agent container. For example, add the following option to your `docker run` command:

```shell
--env DD_LOGS_CONFIG_TAG_FILTERS='{"exclude":["filename:*","dirname:*"],"include":["filename:audit.log"]}'
```

{% /tab %}

{% tab title="Datadog Operator" %}
Set `DD_LOGS_CONFIG_TAG_FILTERS` on the node Agent container:

```yaml
apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: datadog
spec:
  override:
    nodeAgent:
      env:
        - name: DD_LOGS_CONFIG_TAG_FILTERS
          value: '{"exclude":["filename:*","dirname:*"],"include":["filename:audit.log"]}'
```

{% /tab %}

{% tab title="Helm" %}
Set `DD_LOGS_CONFIG_TAG_FILTERS` in the Helm chart values:

```yaml
datadog:
  env:
    - name: DD_LOGS_CONFIG_TAG_FILTERS
      value: '{"exclude":["filename:*","dirname:*"],"include":["filename:audit.log"]}'
```

{% /tab %}

### Per-source filters{% #per-source-filters %}

Add `tag_filters` to a log source in its integration configuration file, such as `conf.d/<INTEGRATION_NAME>.d/conf.yaml`, to limit the filter to that source. The following example removes the `dirname` tag only from logs collected from `/var/log/my-app/*.log`:

```yaml
logs:
  - type: file
    path: /var/log/my-app/*.log
    service: my-app
    source: custom_log
    tag_filters:
      exclude:
        - "dirname:*"
```

Per-source rules are evaluated before global rules, so a per-source `include` rule can preserve a tag that a global `exclude` rule would otherwise remove.

### Apply and verify filters{% #apply-and-verify-filters %}

After you change tag filters, [restart the Agent](https://docs.datadoghq.com/agent/configuration/agent-commands.md#restart-the-agent). To confirm the filters are applied:

- Run `datadog-agent status -v`. The **Logs Agent** section lists the effective `Tag Filters` for each source that has filters applied.
- Run `datadog-agent stream-logs`. The streamed logs show tags after filtering, matching what the Agent sends to Datadog.

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Tagging Best Practices](https://docs.datadoghq.com/getting_started/tagging.md)
- [Agent Configuration Files](https://docs.datadoghq.com/agent/configuration/agent-configuration-files.md)
- [Container Tagging](https://docs.datadoghq.com/agent/docker/tag.md)
