For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/metrics/guide/tag-indexing-rules.md. A documentation index is available at /llms.txt.

Tag Indexing Rules

Overview

Tag Indexing Rules are centralized configurations that define how Datadog handles metric tags at ingestion. They allow you to proactively control which tags are retained or excluded, helping reduce high cardinality by removing unnecessary tags and ensuring consistent tagging across your organization.

Tag Indexing Rules operate on groups of metrics identified by name or prefix. They apply to both existing and newly ingested metrics that match the defined patterns, reducing the need for reactive cleanup or code changes while enabling more predictable cost management.

Create a tag rule

After you create a rule, Datadog automatically applies it to all matching metrics.

  1. Navigate to Metrics → Settings.
  2. Click + Create Rule.
  3. Select Configure Tag Indexing Rule.
The Create Rule dropdown menu in Metrics Settings, showing the Configure Tag Indexing Rule option highlighted.

Step 1: Set rule details

Enter a rule name. Use a descriptive name that clearly identifies the purpose of the rule.

Step 2: Define rule scope

Choose which metrics the rule applies to. Define the rule scope with one or more of the following options:

Metric names or prefixes
Apply the rule to specific metric names or namespaces (for example, http.*, db.query.*)
Prefix exceptions
Exclude specific prefixes from the rule scope (for example, apply to http.* but exclude http.client.*)
The Choose Metrics step showing a rule scoped to http.* with http.client.* excluded as a sub-prefix.

If multiple rules apply to the same metrics, Datadog evaluates them in order. Optionally, use Override behavior to replace previously evaluated rules for the selected metrics.

Step 3: Configure tag behavior

Define how the rule handles tags for metrics in scope.

Merge or override existing configurations

Choose whether this rule builds on or replaces existing tag configurations.

  • Merge (default)—applies this rule on top of existing tag configurations. Metrics with no prior configuration are unaffected.
  • Override—ignores all other rules that apply to the same prefixes and enforces this rule exclusively. Select the Override all other rules that apply to these prefixes option to enable this behavior.

Note: Use Override behavior on a narrower rule to prevent a broader rule’s excluded tags from stacking. For example, suppose Rule 1 uses Merge behavior to exclude host from dd.*, and Rule 2 excludes app_name from dd.payments.*. If Rule 2 also uses Merge, both host and app_name are dropped from dd.payments.* metrics. If Rule 2 uses Override, only app_name is dropped (Rule 1’s effect is overridden for that prefix).

Apply to new metrics only

Applies this rule only to metrics submitted after the rule is created. Existing metrics that match the rule remain unchanged.

Select tags to include or exclude

Choose whether to use an allowlist or a blocklist for tag filtering.

  • Include tags—use an allowlist of tags that remain queryable.
  • Exclude tags—use a blocklist to define non-queryable tags.

Add the tag keys you want to include or exclude.

The Choose Tags step showing the Include tags option selected with tag keys entered.

After you configure tag behavior, the preview shows a list of affected metrics (up to 100 in the UI).

The Preview affected metrics panel showing a list of metrics matching the rule scope.

Limitations

  • Exclude rules take effect after Datadog observes a tag on a metric.
  • Datadog evaluates rules sequentially, and each subsequent rule either builds on or replaces earlier configurations.

Modify a rule

Navigate to Metrics → Settings → Rules to modify existing rules. After you make changes, Datadog automatically applies them to all matching metrics.

Edit a rule

Select a rule to open its details panel, then click Edit to change the rule’s scope, tag selection, or merge and override behavior.

The rule details side panel showing the rule type, scope, action, tags, and options, with an Edit button.

Reorder rules

Drag rules to change the evaluation order. The evaluation order determines how rules interact when multiple rules apply to the same metrics.

Delete a rule

Remove rules that are no longer needed. When you delete a rule, Datadog recomputes the tag configuration for affected metrics based on the remaining rules.

Override rules for a specific metric

To exempt a metric from tag rules, open the metric’s details side panel in Metrics Summary, select Configure This Metric Individually, and set the metric to retain all tags. Retaining all tags bypasses all tag rules for that metric without modifying the rules themselves.

To reapply rules, restore the metric’s default configuration from the same panel.

Rule precedence

When multiple rules apply to the same metrics, Datadog evaluates them sequentially. Rule order matters because:

  • Rules lower in the evaluation order modify the results of earlier rules
  • Override behavior overwrites previous configurations for matching metrics
  • Merge behavior builds on existing configurations
  • When multiple rules use Override behavior, the last applied rule determines whether the final configuration is in include or exclude mode

Reorder rules on the Rules page to change which rule takes precedence. See the following examples to understand how different orders produce different results.

Precedence examples

Example 1: Merge and Override behavior

Tag rules can either override an existing configuration or merge with it. The choice determines whether a rule resets the tag configuration or builds on top of what already exists.

Starting tags:
host, env, service, team

Diagram showing two rules applied to metrics: Rule 1 excludes env from all metrics using Override, and Rule 2 includes env for infra metrics using Merge.

Key insight: The env tag is re-added only to the infra.* metrics.

Example 2: Rule order

When multiple rules apply to the same metrics, Datadog evaluates them in order. Rules that run later can refine or override the effects of earlier rules.

Starting tags:
host, env, service

In this example, Rule 2 uses an Include configuration, which acts as an allowlist. Only the listed tags are retained; any tag not listed is dropped.

Order 1: Specific rule first

Diagram showing the specific rule evaluated first: Rule 1 excludes host from infra.server metrics, then Rule 2 includes host for all infra metrics, restoring the tag.

Key insight: Rule 1 removes the host tag, then Rule 2 re-adds host.

Order 2: General rule first

Diagram showing the general rule evaluated first: Rule 1 includes host for all infra metrics, then Rule 2 excludes host from infra.server metrics, removing the tag.

Key insight: The host tag is removed last, and stays removed.

Example 3: Exception to a broad rule

Use a broad rule with Override behavior to exclude a tag globally, then use a targeted rule with Merge behavior to restore the tag for specific metrics.

Starting tags: node, env, pod

Diagram showing a broad Override rule excluding pod from all kube metrics, then a narrow Merge rule including pod for kube.node metrics, preserving all original tags.

Key insight: When a broad exclude and a narrow include cancel each other out for a metric, no tag restrictions are applied and all original tags are preserved.

Example 4: Multiple exceptions to a broad rule

Layer multiple rules with Merge behavior on top of a broad rule with Override behavior to restore different tags for different metric prefixes. Metrics matching more specific prefixes accumulate more restorations.

Starting tags: team, pod, env

Diagram showing a broad Override rule excluding all tags, then two Merge rules restoring different tags for different prefixes, with metrics matching both prefixes getting both sets of tags restored.

Key insight: Multiple inclusion rules with Merge behavior, applied after an exclusion rule with Override behavior, are additive (a metric matching two exception prefixes gets both sets of tags restored).

Metrics without Limits™ compatibility

Tag rules do not automatically override existing Metrics without Limits™ (MWL) per-metric configurations. Existing MWL configurations take precedence, and Datadog preserves them when you create or modify tag rules.

If a metric’s MWL configuration is deleted, tag rules automatically apply to that metric based on the current rule order.

To exclude a specific metric from all tag rules without deleting them, use the metric’s details side panel to retain all tags. To reapply rules, restore the metric’s default configuration from the same panel.

Further reading