Control metric cardinality by applying metric_relabel_configs to drop or aggregate high-cardinality labels

domain: prometheus.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Identify high-cardinality label values by querying topk(20, count by (__name__, label_name)({__name__=~".+"})) in Prometheus or using the TSDB status endpoint /api/v1/status/tsdb
  2. Add metric_relabel_configs to the affected scrape job in prometheus.yml; metric_relabel_configs run after scraping and before storage
  3. To drop a metric entirely use action: drop with a regex matching the metric name in the source_labels: [__name__] field
  4. To remove a specific label use action: labeldrop with a regex matching the label name; this reduces series count without dropping the metric
  5. To replace dynamic label values with a fixed bucket use action: replace with a regex capturing groups and a replacement string (e.g., normalize user_id values to 'user')
  6. Reload Prometheus with a SIGHUP or POST /api/v1/-/reload and verify cardinality reduction with the TSDB status endpoint

Known gotchas

Related routes

Use promtool tsdb analyze and the Prometheus TSDB API to identify and remediate high-cardinality metric labels
prometheus.io · 6 steps · unrated
Control Grafana Loki stream cardinality by applying label best practices and configuring per-tenant stream limits
grafana.com/docs/loki · 6 steps · unrated
Configure cardinality control in an OTel Collector metrics pipeline using the metricstransform processor and the transform processor to aggregate away high-cardinality dimensions
opentelemetry.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans