How do you enforce cardinality limits so one team cannot blow up the shared system?
AdvancedProductionCardinality Control & Cost
Answer
Layered guards:
# Per scrape job in Prometheus
- job_name: team-x
sample_limit: 50000
label_limit: 30
label_value_length_limit: 200
- Prometheus Operator:
enforcedSampleLimiton the Prometheus resource,sampleLimiton ServiceMonitors. - Mimir:
max_global_series_per_userandmax_global_series_per_metricper tenant. - CI: lint instrumentation PRs for label names like
user_id.
Exceeding sample_limit fails the whole scrape (up == 0), which is visible and forces a fix.
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 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