Interview Prep/Monitoring & Observability/PromQL and recording rules

`rate()` applied to a gauge shows huge spikes

BeginnerTroubleshootingPromQL and recording rules
Answer

Likely causes → rate() assumes a monotonically increasing counter; every decrease in a gauge is treated as a counter reset, producing big fake increases.

Diagnose → Check # TYPE on the metric's /metrics output.

Fix → For gauges use deriv(), delta(), avg_over_time() or the raw value. Use rate()/increase() only on counters (_total, _count, _sum, _bucket).

Prevent → Follow naming conventions so types are obvious.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on PromQL and recording rules