Interview Prep/Monitoring & Observability/Cardinality Control & Cost

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: enforcedSampleLimit on the Prometheus resource, sampleLimit on ServiceMonitors.
  • Mimir: max_global_series_per_user and max_global_series_per_metric per 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.

All Monitoring & Observability questions

More on Cardinality Control & Cost