Tools / Monitoring and Observability Interview Questions
What is cardinality in metrics and why does high cardinality cause problems?
Cardinality in metrics refers to the number of unique label value combinations that a metric can produce. A metric like http_requests_total{method, status_code, endpoint} with 5 methods, 20 status codes, and 1,000 endpoints generates up to 100,000 unique time-series. Each unique combination is called a label set or series.
High cardinality causes problems in time-series databases like Prometheus because each unique series requires its own storage, indexing, and memory overhead. The Prometheus TSDB keeps an inverted index of all label values in RAM. When you add a label like user_id or request_id — which can have millions of values — the number of series explodes. This is called a cardinality explosion, and it can OOM-kill a Prometheus server within minutes.
Common cardinality pitfalls include: adding user IDs, session tokens, IP addresses, or UUIDs as metric labels; using unbounded string values as labels; or creating per-endpoint metrics for every URL path in an API (especially with path parameters like /user/{id}).
Solutions include: using logs or traces for high-cardinality data instead of metrics; normalizing high-cardinality labels into fixed buckets; using recording rules to pre-aggregate before storage; or migrating to backends that handle high cardinality better than vanilla Prometheus, such as VictoriaMetrics or Thanos.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
