---
isPrivate: true
title: Tag Indexing Rules
description: >-
  Use tag rules to configure metrics proactively, after ingestion, so you can
  mitigate high cardinality and enforce consistent tag management across your
  organization.
breadcrumbs: Docs > Metrics > Metrics Guides > Tag Indexing Rules
---

# Tag Indexing Rules

## Overview{% #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{% #create-a-tag-rule %}

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

1. Navigate to [**Metrics → Settings**](https://app.datadoghq.com/metric/settings).
1. Click **+ Create Rule**.
1. Select **Configure Tag Indexing Rule**.

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/configure_tag_indexing_rule.69a6a50734b28cddb57e4a2488b39dac.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/configure_tag_indexing_rule.69a6a50734b28cddb57e4a2488b39dac.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Create Rule dropdown menu in Metrics Settings, showing the Configure Tag Indexing Rule option highlighted." /%}

### Step 1: Set rule details{% #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{% #step-2-define-rule-scope %}

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

{% dl %}

{% dt %}
Metric names or prefixes
{% /dt %}

{% dd %}
Apply the rule to specific metric names or namespaces (for example, `http.*`, `db.query.*`)
{% /dd %}

{% dt %}
Prefix exceptions
{% /dt %}

{% dd %}
Exclude specific prefixes from the rule scope (for example, apply to `http.*` but exclude `http.client.*`)
{% /dd %}

{% /dl %}

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/define_rule_scope.366c50c27303d189583584d890732b88.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/define_rule_scope.366c50c27303d189583584d890732b88.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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{% #step-3-configure-tag-behavior %}

Define how the rule handles tags for metrics in scope.

#### Merge or override existing configurations{% #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{% #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{% #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.

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/configure_tag_behavior.b8b096925dfb3aeec3ba147c2f792443.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/configure_tag_behavior.b8b096925dfb3aeec3ba147c2f792443.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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).

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/preview_affected_metrics.cae8c543947baa5afac8bf1fe8a956ea.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/preview_affected_metrics.cae8c543947baa5afac8bf1fe8a956ea.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Preview affected metrics panel showing a list of metrics matching the rule scope." /%}

### Limitations{% #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{% #modify-a-rule %}

Navigate to [**Metrics → Settings → Rules**](https://app.datadoghq.com/metric/settings/policies) to modify existing rules. After you make changes, Datadog automatically applies them to all matching metrics.

### Edit a rule{% #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.

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/edit_rule_configuration.6beeb57b839151cc502476879cf517df.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/edit_rule_configuration.6beeb57b839151cc502476879cf517df.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The rule details side panel showing the rule type, scope, action, tags, and options, with an Edit button." /%}

### Reorder rules{% #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{% #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{% #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{% #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](https://app.datadoghq.com/metric/settings/policies) to change which rule takes precedence. See the following examples to understand how different orders produce different results.

## Precedence examples{% #precedence-examples %}

### Example 1: Merge and Override behavior{% #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`

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/merge_vs_override.560cd0eae12e6b8ef842904ebe9ff2a3.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/merge_vs_override.560cd0eae12e6b8ef842904ebe9ff2a3.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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{% #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{% #order-1-specific-rule-first %}

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/rule_order_1.5d3088aa71b329fdabee613c37c54e87.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/rule_order_1.5d3088aa71b329fdabee613c37c54e87.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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{% #order-2-general-rule-first %}

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/rule_order_2.7c8ef37dc21805d158ef9e9a3d544b8c.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/rule_order_2.7c8ef37dc21805d158ef9e9a3d544b8c.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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{% #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`

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/broad_exclude_narrow_exception.66081ae7112b8bbcd45c6856a97cd975.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/broad_exclude_narrow_exception.66081ae7112b8bbcd45c6856a97cd975.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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{% #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`

{% image
   source="https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/multiple_exceptions.4aef350de57008b2fb6135d124621e41.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/metrics/guide/tag_indexing_rules/multiple_exceptions.4aef350de57008b2fb6135d124621e41.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="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{% #metrics-without-limits-compatibility %}

Tag rules do not automatically override existing [Metrics without Limits™](https://docs.datadoghq.com/metrics/metrics-without-limits.md) (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{% #further-reading %}

- [Custom Metrics Billing](https://docs.datadoghq.com/account_management/billing/custom_metrics.md?tab=countrate)
- [Best Practice for Custom Metric Governance](https://docs.datadoghq.com/metrics/guide/custom_metrics_governance.md)
- [Dynamically control your custom metrics volume with Metrics without Limits™](https://www.datadoghq.com/blog/metrics-without-limits/)
