What causes a cardinality explosion, and how do you prevent it? [Intermediate]
Answer
A cardinality explosion happens when a metric label has many or unbounded values, or when multiple labels multiply together unexpectedly. It is prevented by limiting labels to stable, bounded dimensions and reviewing instrumentation before release.
Technical explanation
Common causes are raw URL paths with IDs, customer IDs, pod UIDs, exception messages, dynamic queue names, and per-request labels.
Use templated routes like /orders/{id} instead of /orders/12345.
Apply metric relabeling carefully, but fixing instrumentation at source is the best solution.
Hands-on example
Example: replace http_requests_total{path='/users/123/orders/456'} with http_requests_total{route='/users/{user_id}/orders/{order_id}', method='GET', status='200'}. For user-level debugging, use logs or traces, not metric labels.
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
- What is observability, and how is it different from traditional monitoring? [Basic]
- What are the three pillars of observability (metrics, logs, traces)? [Basic]
- What is the difference between monitoring and observability in practice? [Basic]
- What are the four golden signals of monitoring? [Basic]
- What is the difference between the USE method and the RED method? [Basic]
- When would you use the USE method versus the RED method? [Basic]
- What is an SLI, an SLO, and an SLA, and how do they relate? [Basic]
- How do you choose good SLIs for a service? [Basic]