Q: Your Prometheus server is running out of memory and crashing every few hours. How do you troubleshoot and fix this?
Prometheus OOMs almost exclusively due to High Cardinality in the metrics it scrapes or the queries being run against it.
Want to master this scenario in a live sandbox? The Linux Foundation's Prometheus Certified Associate (PCA) & Monitoring Labs covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "Logs tell you what happened, metrics tell you where to look, and distributed traces pinpoint the exact slow component. The interviewer is testing: High cardinality, metric relabeling, Prometheus architecture.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Initial Diagnostics & Root Cause Analysis
Prometheus OOMs almost exclusively due to High Cardinality in the metrics it scrapes or the queries being run against it.
- Find High Cardinality: When it's running, query
topk(10, count by (__name__) ({__name__=~".+"}))to find which metrics have millions of series. It's often caused by developers putting unbounded variables (like user IDs, session tokens, or full URLs) into metric labels instead of bounded HTTP status codes or methods. - Mitigation: Use
metric_relabel_configsin the scrape config todropthe problematic metrics or strip the offending high-cardinality labels before ingestion. - Long-term: Talk to the developers to remove high cardinality labels. If the scale is simply huge, implement a horizontal scaling solution like Thanos or Cortex, rather than relying on a single Prometheus instance.
Remediation & Permanent Safeguards
- Find High Cardinality: When it's running, query topk(10, count by (__name__) ({__name__=~".+"})) ...
- Mitigation: Use metric_relabel_configs in the scrape config to drop the problematic metrics or st...
- Long-term: Talk to the developers to remove high cardinality labels. If the scale is simply huge,...
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Injecting high-cardinality label dimensions (such as user IDs or request UUIDs) into Prometheus metrics when configuring Observability Prometheus server High-cardinality label values cause exponential time-series growth, consuming gigabytes of TSDB memory and crashing Prometheus servers.
- Evaluating application performance solely through arithmetic mean or p50 latency while ignoring tail latency (p99) when configuring Observability Prometheus server Averages hide catastrophic tail latency outages where 1% of high-value user transactions suffer severe timeouts.
- Failing to inject and extract W3C distributed trace context across message brokers and RPC calls when configuring Observability Prometheus server Breaking distributed trace context propagation fragments end-to-end transaction waterfalls into disconnected, un-correlatable trace segments.
- Configuring alert rule evaluation intervals without sufficient duration damping (for: 5m), inducing alert flap when configuring Observability Prometheus server Instant alerts triggered by transient sub-second CPU or latency blips page on-call engineers unnecessarily and dilute response urgency.