How does Prometheus handle high cardinality, and why is it a problem? [Intermediate]
Answer
Prometheus handles high cardinality poorly when too many unique label combinations create too many time series. It increases memory, disk, CPU, query latency, and remote-write cost, and can make Prometheus unstable.
Technical explanation
Cardinality is the number of unique time series, not just the number of metric names.
Labels like user_id, request_id, session_id, full URL, IP address, or order ID can create unbounded series.
Prevention is better than cleanup: enforce metric naming and label-review standards before production.
Hands-on example
Hands-on: run topk(20, count by (__name__)({__name__=~'.+'})) to identify large metrics, and count by (label_name) is not directly available, so use tooling such as promtool, Mimirtool, or TSDB status. Drop bad labels at scrape or instrumentation before retention cost grows.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- How does Prometheus storage (TSDB) work, and what is the retention model? [Intermediate]
- What is an alerting rule, and how does it differ from a recording rule? [Basic]
- What is the difference between Thanos and Cortex/Mimir at a high level? [Intermediate]
- What is a recording rule, and when would you use one? [Basic]
- How does Prometheus integrate with Kubernetes service discovery? [Intermediate]
- How do you compute a 95th percentile latency from a histogram in PromQL (histogram_quantile)? [Basic]
- What is the Prometheus Operator, and what are ServiceMonitor and PodMonitor? [Intermediate]
- What is the difference between rate() and irate()? [Basic]