Interview Prep/Monitoring & Observability/Cardinality Control & Cost

How do you find which metrics and labels are driving cardinality?

IntermediateProductionCardinality Control & Cost
Answer
# Prometheus TSDB stats (also in the UI at Status -> TSDB Status)
curl -s http://prometheus:9090/api/v1/status/tsdb | jq '.data.seriesCountByMetricName[:10]'
promtool tsdb analyze /prometheus
topk(10, count by (__name__) ({__name__=~".+"}))
count(count by (path) (http_requests_total))

Mimir has a cardinality API (/api/v1/cardinality/label_names), Grafana Cloud has the Cardinality Management dashboards, and VictoriaMetrics has a cardinality explorer. Run the expensive {__name__=~".+"} query off-peak.

All Monitoring & Observability questions

More on Cardinality Control & Cost