RousselTMLEARNING

Article · Datadog: from discovery to expertise

Metrics and tags

1. Unified tagging #

Three tags to link everything.

env, service, version #

Datadog links the metrics, traces, logs and profiles of a service through three reserved tags: env, service and version. You set them once, at the source:

# Conteneur Docker
docker run -e DD_ENV=prod -e DD_SERVICE=checkout -e DD_VERSION=2.4.1 \
  -l com.datadoghq.tags.env=prod -l com.datadoghq.tags.service=checkout -l com.datadoghq.tags.version=2.4.1 ...

# Pod Kubernetes
metadata:
  labels:
    tags.datadoghq.com/env: prod
    tags.datadoghq.com/service: checkout
    tags.datadoghq.com/version: "2.4.1"
Good practice: With version, a service's page automatically compares deployments (latency, errors): deployment tracking with no effort.

2. Querying metrics #

Query syntax.

Queries #

avg:system.cpu.user{env:prod,service:checkout} by {host}
sum:trace.http.request.errors{service:checkout}.as_count() / sum:trace.http.request.hits{service:checkout}.as_count()
top(avg:kubernetes.cpu.usage.total{kube_namespace:boutique} by {pod_name}, 10, 'mean', 'desc')
anomalies(avg:aws.elb.latency{env:prod}, 'agile', 2)
ElementRole
avg:, sum:, max:Space aggregation (across series)
{...}Filter by tags
by {...}Grouping
.as_count(), .as_rate()Counter interpretation
.rollup(avg, 300)Time aggregation

3. Custom metrics and cost #

DogStatsD and cardinality.

DogStatsD #

# Envoyer une métrique en UDP (port 8125 de l'agent)
echo -n "boutique.commandes:1|c|#env:prod,service:checkout,moyen_paiement:carte" | nc -u -w1 localhost 8125
echo -n "boutique.panier.montant:129.9|d|#env:prod,service:checkout" | nc -u -w1 localhost 8125
from datadog import initialize, statsd
initialize(statsd_host="localhost", statsd_port=8125)
statsd.increment("boutique.commandes", tags=["moyen_paiement:carte"])
statsd.distribution("boutique.panier.montant", 129.9)
Common mistake: Each unique combination of name and tags is a billed custom metric. A user_id or order_id tag can create hundreds of thousands of series and multiply the bill.

Controlling cost #

  • List the largest custom metrics (Metrics Summary, Usage pages).
  • Use Metrics without Limits to keep only the tags actually queried.
  • Prefer distributions to multiple gauges for percentiles.
  • Do not replicate useless Prometheus metrics in Datadog (filter at collection).

📄 Metrics and tags in Datadog: unified tagging, DogStatsD and cardinality →

My progress

  • ⏱ Estimated time : ≈ 5 min

Sign in to track your progress and take notes. Sign in

💬 Recent discussions about this course

Ask a question about this lesson →See all discussions about this course

Recommended Articles

Advanced Datadog metrics: types, aggregations, cardinality and Metrics without Limits

Master Datadog metrics: types (count, rate, gauge, histogram, distribution), time and space aggre...

Datadog best practices: tags, costs, alerts and governance

Checklist for using Datadog effectively: unified tagging, cost control (hosts, logs, custom metri...

Datadog platform architecture: sites, organizations, keys and data model

Understand Datadog's architecture: data sources (agent, cloud integrations, SDKs, OpenTelemetry),...

Datadog dashboards and notebooks: widgets, template variables and best practices

Design useful Datadog dashboards: widget types, template variables, groups, Powerpacks, formulas,...

Datadog: the SaaS observability platform at a glance

What Datadog is, its products (infrastructure, logs, APM, RUM, synthetics, security), its concept...

Monitors, SLOs, dashboards and Datadog as code

Create effective monitors (metrics, logs, APM, composites, anomalies), SLOs, dashboards, and mana...

Advanced Datadog APM: sampling, retention, profiler and Software Catalog

Go further with Datadog APM: ingestion control and sampling, retention filters, trace metrics, Co...

Logs in Datadog: collection, pipelines, indexes and volume control

Collect logs with the agent, structure them with pipelines and processors (grok), use facets and ...

Service types in Dynatrace: web, database, messaging, custom and unified services

What a service is for Dynatrace, the automatically detected service types (web requests, web serv...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!