Skip to content

Commit cd3d403

Browse files
authored
Merge pull request DataDog#7597 from DataDog/sarina/advanced-tagging
Add unified tagging advanced usage guide
2 parents 2df0fa8 + 7a5012e commit cd3d403

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Unified Tagging Advanced Usage Guide
3+
kind: guide
4+
aliases:
5+
- /developers/guide/unified-tagging-advanced-usage
6+
---
7+
8+
## Overview
9+
10+
This guide suggests ways to configure and migrate to [unified service tagging][1] based on specific use cases.
11+
12+
## Using Custom Tags
13+
14+
You can continue to use the `env` `service` and `version` tags as they are configured for unified service tagging. However, if you'd like to achieve a unified tagging experience with your own custom tags, there are several options available which are listed below.
15+
16+
**Note**: While some products support arbitrary tags, others have more specific expectations. As such, navigation between products might be difficult if one data source has a tag that another does not have or does not support.
17+
18+
### Containerized environments
19+
20+
#### Metrics
21+
22+
Since tags can be appended to data points, you have a lot of freedom in setting desired tags. Autodiscovered tags are automatically added to all metrics collected.
23+
24+
#### APM
25+
26+
`env` and `service` are core tags in APM, so it is not possible to replace them with differently named tags. However, APM does allow for data to be [aggregated along more primary tags][4] than just `env`. Since host tags are added to traces and trace metrics, they can be used as well (e.g., availability-zone).
27+
28+
Autodiscovered tags associated with containers are added to `container_info` in span metadata. However, these container tags are not part of the [whitelisted tags][2] for trace metrics.
29+
30+
31+
#### Logs
32+
33+
Similar to APM, `service` is a core tag that is used to help organize logs data. Additionally, it is not possible to link from a log to the related APM service without it.
34+
35+
Similar to metrics, however, Autodiscovered tags for the container as well as host tags for the agent are added to all logs.
36+
37+
You also have the ability to add custom fields to your logs in-code, which can be mapped to tags or attributes downstream in a [Datadog log processing pipeline][3].
38+
39+
## Using Standard Labels
40+
41+
We recommend using both standard labels and environment variables. However, standard labels can be seen as an alternative to using environment variables, particularly for applications that will not benefit from using those variables in their runtime. 3rd party software like Redis, MySQL, and Nginx are a few examples. Since these services still generate infrastructure metrics and data from integration checks, it's valuable to have all of that data tagged with `env`, `service`, and `version`.
42+
43+
If you would like to tag Kubernetes state metrics with `env`, `service`, and `version` then the standard labels offer the easiest way. The `DD` environment variables of a container cannot be used by the Agent to tag these metrics, so the labels are a more natural option.
44+
45+
### Declaring environment as a label
46+
47+
Configuring `env` closer to the source of the data (e.g., APM traces, logs) helps to avoid inconsistencies where the Agent `env` might be different. Making `env` part of the service's configuration guarantees a service-centric source of truth.
48+
49+
### Using standard labels with existing Kubernetes tags annotation
50+
51+
Kubernetes users can continue to use these general tags. However, using the specific labels has a few benefits:
52+
53+
- You can directly reference them for environment variable injection via the Kubernetes downward API.
54+
- The service standard label can simplify the definition of service for logs.
55+
56+
### Using standard labels for specific containers
57+
58+
Since the `DD` environment variables are injected at the container level, they can differ from container to container. However, if you want to use the standard labels as well for specific containers, then you will need to use their container-specific variants:
59+
60+
```yaml
61+
tags.datadoghq.com/<container>.env
62+
tags.datadoghq.com/<container>.service
63+
tags.datadoghq.com/<container>.version
64+
```
65+
66+
[1]: /getting_started/tagging/unified_service_tagging
67+
[2]: /metrics/distributions/#customize-tagging
68+
[3]: /logs/processing/pipelines/
69+
[4]: /tracing/guide/setting_primary_tags_to_scope/

0 commit comments

Comments
 (0)