🎓 A1Learner
🔍
0 of 50 lessons completed

PromQL: rate, irate and increase

Rate turns a counter into a speed. It answers how fast requests arrive, not how many have ever arrived.

Requests per second

Rate over five minutes gives a steady speed for the shop.

rate(http_requests_total{job="shopsentry"}[5m])

Total growth in five minutes

Increase gives the count gained in the window, not a speed.

increase(http_requests_total{job="shopsentry"}[5m])

The latest speed, for debugging

Irate uses only the last two samples, so it jumps fast.

irate(http_requests_total{job="shopsentry"}[5m])

Example

sum(rate(http_requests_total{job="shopsentry"}[5m]))

Key points

  • A counter only goes up, so its raw value never shows speed.
  • Use rate to find the per-second speed of a counter over a window.
  • Use irate to find the speed from the last two samples only.
  • Use increase to find the total growth of a counter over a window.
  • Use rate for alerts, because it smooths short spikes.
  • Use irate for debugging spikes, because it reacts at once.
  • Never use irate for alerts, because one slow scrape can fire it.
  • Keep the window at least four times the scrape interval.

In this example, rate turns each request counter into a per-second speed, and sum adds the speeds into one total for the whole shop. The number is the real request speed from the live ShopSentry lab.

Note

A 15 second scrape interval needs a window of at least one minute.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

Which function should an alert use for request speed?