Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 37 ยท Cost and Operations

Cost Management and Custom Metrics

Keep your Datadog bill predictable: understand custom metric cardinality, log ingestion versus indexing, usage metrics, Metrics without Limits and cost-aware tagging.

Observability tools are billed by volume, and volume grows quietly. A single tag that holds a user ID can multiply a metric into millions of series overnight. This lesson explains what drives cost in Datadog and how to control it without going blind.

Pricing, SKUs and limits change and differ per contract. Numbers here are illustrative; use your own Plan & Usage page for real data. The calculators are labelled stand-ins that teach the shape of the maths.

What you pay for

Area Billed mainly by
Infrastructure Number of hosts (or containers, in some plans), per hour
Custom metrics Number of unique metric+tag combinations (time series), averaged over the month
Logs Ingested volume (GB) plus indexed log events (per million), plus retention days
APM APM hosts or containers, plus ingested and indexed spans
Synthetics Number of test runs
RUM Sessions (and replay sessions)
Security products Hosts, analysed log volume, scanned data

Many accounts include a monthly allotment of custom metrics per host, and you pay for the excess.

Custom metrics and cardinality

A custom metric is one that does not come from an Agent integration, such as orders.created sent by your code with DogStatsD or the API. Datadog counts each unique combination of metric name and tag values as a separate time series. This number is the cardinality.

If orders.created has tags region (4 values), payment_method (5) and plan (3), it can create up to 4 x 5 x 3 = 60 series. Add user_id with 100,000 values and you may have six million series. That is the classic cost explosion.

JS Stand-in: custom metric cardinality

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The upper bound is the product, but real usage is lower, because only combinations that actually occur are counted. It still grows fast.

Rules for tags on custom metrics:

  • Use tags with a bounded number of values: region, plan, status class, service.
  • Never use IDs (user, request, session, container ID, timestamps) as tags. Put them in logs or trace tags instead.
  • Prefer status_class:5xx over status_code:503 unless you need every code.
  • Review Metrics > Summary: it lists each metric, its tags and its cardinality.

Metrics without Limits

With Metrics without Limits, you decide which tags are queryable for a metric and which are only ingested. You keep the raw data flowing but index only a smaller tag set (for example region, plan), reducing the number of indexed series and cost. You configure it per metric on the Metrics Summary page (Manage Tags). Metric type matters: for counts and rates you choose aggregations such as sum; for gauges, avg/min/max, so the stored values still make sense. You can also see which tags are really used in dashboards and monitors so you do not remove one that matters.

Logs: ingest versus index

Logs are the most common surprise. There are two steps:

  1. Ingest: Datadog receives and processes every log line (pipelines, parsing). Billed per GB.
  2. Index: the lines you keep searchable for N days. Billed per million events.

You choose what to index with exclusion filters and index routing. Typical approach:

  • Index all errors and warnings for 15 to 30 days.
  • Sample info logs (say 10%) or exclude them from indexing.
  • Exclude noisy sources: health checks, load balancer pings, debug logs.
  • Send everything else to Archives (object storage in S3, GCS or Azure Blob) for cheap long-term storage, and rehydrate only when you investigate.
  • Generate log-based metrics for counts and rates you graph often, so you do not need to index the lines to see the numbers.
  • Use Flex Logs or similar low-cost tiers when your plan offers them for rarely searched data.
JS Stand-in: log index budget

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Watch usage in Datadog

  • Plan & Usage (under your account menu) shows billable usage by product and by time, with an attribution by tag (team, service) if your plan includes it.
  • Estimated Usage metrics (datadog.estimated_usage.*, for example datadog.estimated_usage.logs.ingested_events) can be graphed and monitored like any metric.
  • Create a usage monitor: alert if ingested logs jump by 50% against last week, and also a forecast for the month.
  • Add team tags to services so you can chargeback or show-back costs to teams.

Checklist

  1. Standardise tags (env, service, team); ban IDs as tags.
  2. Review top 20 custom metrics by cardinality monthly.
  3. Configure exclusion filters and archives before logs explode.
  4. Set up usage alerts and a monthly cost review with team owners.
  5. Delete dashboards, monitors and metrics nobody uses.

Cost control is a design habit, not a one-time clean-up. Add a "does this tag have bounded values?" line to your code review checklist.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What defines one custom metric time series?

    Each distinct name+tags combination counts as its own time series.
  2. 2. Which tag is most dangerous on a custom metric?

    An unbounded identifier multiplies series and cost.
  3. 3. What is the difference between ingesting and indexing logs?

    Ingestion processes all lines; indexing keeps selected lines searchable for a retention period.
  4. 4. How can you graph a log count without indexing every line?

    Log-based metrics turn log counts into metrics at ingestion time.

Summary

  • Cost drivers: hosts, custom-metric series, log ingest and index volume, spans, test runs and sessions.
  • Cardinality is the product of tag value counts: never tag with unbounded IDs.
  • Metrics without Limits keeps raw data but indexes fewer tags.
  • Filter, sample and archive logs; use log-based metrics for common graphs.
  • Monitor your own usage with Plan & Usage and datadog.estimated_usage.*.

Next: API, Terraform and Automation