What scrape interval would you choose, and how does it affect `rate()` windows?
BeginnerScenarioPrometheus and PromQL at Scale
Answer
Situation read → Shorter intervals give finer resolution but cost more series samples, CPU and storage.
What I'd do →
- Default to 15s for application and infrastructure metrics, and 30–60s for low-value exporters (cloud APIs, slow databases).
- The
rate()range must contain at least two samples. As a rule use 4x the scrape interval: 15s scrape means[1m]minimum,[5m]for alerts. - Keep one global
scrape_intervaland override per job only with a reason. - Match Grafana's
$__rate_intervalvariable, which accounts for the interval.
Why → If the window contains fewer than two samples, rate() returns nothing and graphs show gaps.
Interview tip → Mention that storage cost scales linearly with scrape frequency.
More on Prometheus and PromQL at Scale
Prometheus memory has grown to 60 GB and keeps climbing. How do you find the cause?IntermediateA developer added `user_id` as a metric label. What is the problem and what do you advise?BeginnerYour dashboard shows the average of per-pod p99 latencies. Why is it wrong, and how do you compute a correct fleet-wide p99?IntermediateChoose histogram bucket boundaries for a service with a 300 ms latency SLO.AdvancedYou have 500 short-lived batch jobs that finish before Prometheus can scrape them. How do you capture their metrics?IntermediateYour EC2 fleet autoscales constantly. How do you keep Prometheus targets up to date?Intermediate