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.
More on Cardinality Control & Cost
What is cardinality and why is it the main cost driver for metrics?BeginnerWhich labels should never appear on metrics?BeginnerHow do you enforce cardinality limits so one team cannot blow up the shared system?AdvancedHow do you drop or aggregate metrics you do not need?IntermediateHow do histograms affect cardinality, and how do you control it?IntermediateHow do you estimate the monthly cost of a new metric before it ships?Intermediate