How do you handle a cardinality explosion that is happening right now?
IntermediateProductionCardinality Control & Cost
Answer
- Identify the metric and job via TSDB status or
topk(10, count by (__name__, job) ({__name__=~".+"})). - Stop the bleeding: add a
metric_relabel_configsdrop orlabeldropfor that job, or setsample_limit, and reload Prometheus (curl -X POST /-/reloadwith--web.enable-lifecycle). - Notify the owning team to fix instrumentation.
- Head memory drops after the next head compaction (every 2 hours).
Prevent with limits and instrumentation review.
More on Cardinality Control & Cost
What is cardinality and why is it the main cost driver for metrics?BeginnerHow do you find which metrics and labels are driving cardinality?IntermediateWhich 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?Intermediate