Tagging Best Practices
Key Takeaways
- Datadog's recommended tag format is key:value (e.g., env:prod, service:checkout).
- Unified service tagging uses three reserved keys: env, service, and version — enabling correlation across metrics, traces, and logs.
- Prefer tags over embedding dimensions in metric names (env:prod beats orders.prod.count).
- High-cardinality tags like request_id or ephemeral container IDs multiply timeseries and increase custom metric volume.
- Global tags in datadog.yaml apply host-wide; integration and DogStatsD submissions inherit them automatically.
Quick Answer: Use key:value tags consistently. Datadog recommends unified service tagging with
env,service, andversion. Put dimensions in tags, not metric names. Avoid high-cardinality tags likerequest_idthat explode timeseries count and cost.
Tags are the glue across every Datadog product surface — Metrics Explorer, dashboards, Host Map, monitors, log search, and APM. The Data Collection domain tests tagging as a design discipline, not a cosmetic label. Poor tagging makes dashboards unusable; good tagging lets one metric answer dozens of questions through filters and grouping.
Tag Format and Syntax
Datadog's standard tag format is:
key:value
Examples: env:prod, service:payment-api, region:us-east-1, team:platform.
| Practice | Good | Avoid |
|---|---|---|
| Separator | Colon between key and value | key=value, key/value |
| Consistency | Same key names org-wide | env:prod on some hosts, environment:production on others |
| Case | Lowercase keys and stable values | Random capitalization per team |
| Characters | Alphanumeric, underscores, colons, slashes | Unbounded user-generated strings as values |
In datadog.yaml, global tags use YAML list syntax:
tags:
- 'env:prod'
- 'service:web'
Invalid list syntax (missing quotes, arrow notation, comma-separated strings without brackets) breaks YAML parsing — a Computer Fundamentals crossover topic that appears when editing Agent configs.
Unified Service Tagging
Datadog recommends three reserved tags for cross-product correlation:
| Tag | Purpose | Example |
|---|---|---|
env | Deployment environment | env:staging, env:prod |
service | Logical service name | service:checkout |
version | Build or release identifier | version:2.4.1 |
When the same three tags appear on metrics, traces, and logs, Datadog can correlate signals in the UI — pivot from a latency spike in APM to matching error logs and infrastructure metrics without guessing naming conventions.
On the Exam: Unified service tagging is env + service + version, not
cluster/node/pod(Kubernetes infrastructure tags) and nothost/ip/subnet(network identity tags). Know the official trio.
Setting Unified Tags
Sources include:
datadog.yamlglobaltagslist on the Agent- Container orchestrator labels (converted by Autodiscovery)
- APM tracer
DD_ENV,DD_SERVICE,DD_VERSIONenvironment variables - DogStatsD
tagsparameter on each metric call
Align all sources to the same values per deployment; conflicting service tags between traces and metrics break correlation.
Tags vs Metric Names
A common anti-pattern embeds dimensions in metric names:
| Anti-Pattern | Better Design |
|---|---|
orders.prod.count | Metric orders.count + tag env:prod |
api_latency_us_east | Metric api.latency + tag region:us-east-1 |
| Separate metric per team | One metric + tag team:payments |
Why tags win:
- One query, many slices —
avg:orders.count{*}grouped byenvinstead of maintaining parallel metric names. - Consistent monitors — one monitor template scoped by tag rather than duplicating per environment.
- Cross-signal reuse — the same
env:prodtag filters logs, traces, and metrics.
Cardinality: The Cost and Query Trap
Cardinality is the number of unique tag-value combinations on a metric. Each combination creates a distinct timeseries. Low-cardinality tags (env, region, service) have bounded values. High-cardinality tags grow without limit.
| Tag | Cardinality Risk | Verdict |
|---|---|---|
env:prod | Low (few environments) | Safe |
service:checkout | Low (dozens of services) | Safe |
version:2.4.1 | Medium (releases over time) | Acceptable with retention awareness |
request_id:abc-12839 | Unbounded | Avoid on metrics |
| Ephemeral container ID | Unbounded | Use orchestrator-level tags instead |
Common Trap: Tagging every request with
request_iddoes not help aggregate dashboards — it creates millions of single-point series, increases custom metric billing, and slows queries. Use request IDs in logs and traces, not as metric tags.
Host Tags vs Custom Metric Tags
The Agent automatically applies host tags: cloud provider metadata, availability-zone, instance-type, and hostname. Integration checks add integration-specific tags (db:postgres, nginx_host).
DogStatsD submissions inherit host tags plus any tags passed in the metric call. You do not need to repeat host manually — Datadog associates the series with the reporting host.
Tag-Based Filtering and Grouping Preview
Tags power query operations tested across Data Collection and Visualization domains:
| Operation | Query Pattern (conceptual) | Effect |
|---|---|---|
| Filter | metric{env:prod} | Only production series |
| Exclude | metric{!env:dev} | Everything except dev |
| Group by | metric{*} by {service} | One line per service value |
| Multi-group | by {host,device} | Separate alerts per disk per host |
Design tags so the keys you group by in monitors (host, service, availability-zone) exist at collection time.
Worked Scenario: Tag Refactor
A team emits checkout.latency.prod, checkout.latency.staging, and checkout.latency.dev as separate metrics. Their monitor count tripled and dashboards drifted.
Refactor plan:
- Consolidate to single metric
checkout.latency. - Add
env:prod|staging|devtag at emission (DogStatsD or tracer). - Add unified tags
service:checkoutandversionfrom CI. - Rewrite dashboards to
avg:checkout.latency{*} by {env}. - Replace three monitors with one multi-alert monitor grouped by
env.
This is exactly the design thinking Fundamentals rewards — fewer metric names, richer tag dimensions, lower operational burden.
Reserved vs Custom Tag Keys
Beyond unified service tags, Datadog recognizes common infrastructure keys (availability-zone, kube_deployment, image_name) from cloud and orchestrator metadata. You may add custom keys (team, cost_center, tier) as long as they stay low-cardinality. Document a tagging policy so new services do not invent synonyms (app vs service) that break cross-team dashboards.
Inherited Tags on DogStatsD Metrics
When application code emits statsd.gauge("cache.size", value), the resulting series inherits host tags from the Agent plus any inline tags in the call. You do not need a separate metric per host — hostname association is automatic, which simplifies fleet-wide queries like avg:cache.size{env:prod} by {host}.
Which three tags make up Datadog unified service tagging?
Which tag format is the Datadog-recommended standard?
Which tagging practice is most likely to create custom-metric cardinality problems?
Why is env:prod usually better than putting the environment inside every metric name?