A deploy restarts pods and counters reset. Will `rate()` show a drop? What about `increase()`?
BeginnerScenarioPrometheus and PromQL at Scale
Answer
Situation read → Counters reset to zero on process restart. Prometheus handles that for you.
What I'd do →
rate()andincrease()detect a decrease as a reset and treat the post-reset value as an increase from zero. No negative spike.- Only apply them to counters. For gauges use
deriv()ordelta(). increase(x[1h])israte(x[1h]) * 3600, extrapolated at the window edges, so it may return non-integers like 9.97 for a count that is really 10.- Never graph a raw counter, as its value is meaningless on its own.
Why → Counters make restarts safe and make scraping losses recoverable, which is why they are preferred over gauges for totals.
Interview tip → Mention that irate is for volatile fast graphs only. Do not use it in alerts.
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