Interview Prep/SRE & Reliability/Prometheus SLIs & Recording Rules

Scrapes fail intermittently with `context deadline exceeded`.

IntermediateTroubleshootingPrometheus SLIs & Recording Rules
Answer

Likely causes → The /metrics endpoint takes longer than scrapeTimeout (default 10s): huge cardinality, expensive collectors, or a CPU-throttled pod.

Diagnose →

time curl -s localhost:8080/metrics | wc -l
scrape_duration_seconds{job="checkout"}
scrape_samples_scraped{job="checkout"}

Fix → Reduce cardinality (drop per-user or per-URL labels), raise CPU limits, or increase scrapeTimeout modestly (must stay below the interval).

Prevent → Alert on scrape_duration_seconds approaching the timeout and on sample count growth.

All SRE & Reliability questions Roadmap: SRE & incident response

More on Prometheus SLIs & Recording Rules