What labels should and should not be put on a metric? [Intermediate]
Answer
Metric labels should describe stable, bounded dimensions that are useful for aggregation, such as service, route, method, status, environment, cluster, and dependency. They should not contain unbounded identifiers such as user_id, request_id, session_id, raw URL, or exception message.
Technical explanation
Labels multiply time-series cardinality, so every new label must have operational value.
Keep label semantics consistent across services so dashboards and alerts can be reused.
Use logs and traces for high-cardinality investigative fields, not metrics.
Hands-on example
Example: good metric: http_requests_total{service='checkout', route='/orders/{id}', method='POST', status='201'}. Bad metric: http_requests_total{url='/orders/abc123', user='u987', request_id='...'}. The bad version is expensive and hard to aggregate.
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 the Prometheus Operator, and what are ServiceMonitor and PodMonitor? [Intermediate]
- How does Prometheus integrate with Kubernetes service discovery? [Intermediate]
- What is the difference between Thanos and Cortex/Mimir at a high level? [Intermediate]
- How does Prometheus storage (TSDB) work, and what is the retention model? [Intermediate]
- What is the Splunk data pipeline (input, parsing, indexing, search)? [Intermediate]
- How does Prometheus handle high cardinality, and why is it a problem? [Intermediate]
- What is the difference between a Splunk forwarder, indexer, and search head? [Intermediate]
- What is the difference between a universal and a heavy forwarder? [Intermediate]