World map

 

BM: Baca dalam Bahasa Melayu

World O2: Counters

rate() and increase()

You will learn: how to turn a counter into 'how fast' and 'how many', even when the app restarts.

Checked with Prometheus 3 on 1 Nov 2026

The problem

The nasi lemak counter at SS15 says 300. Is the stall busy right now?

Pick one answer.

Try it

rate(): How fast a counter grows, per second, averaged over a window. It handles restarts. tells how fast a counter grows, per second, over a window.

Wrap it: rate(kedai_orders_total[5m]). Then Run.

Metrics in this data (tap to add):

Time 0 is when the data starts. The query looks back from the eval time.

Predict

Nasi lemak at SS15 goes 0, 30, 60, 90… one step each minute. What does rate() say?

Pick one answer.

Watch

Restarts reset counters to 0. rate() notices the drop and keeps counting up.

Run it at 16m: the Bangsar till restarted. Then wrap it in rate(…[5m]) and Run again.

Metrics in this data (tap to add):

Time 0 is when the data starts. The query looks back from the eval time.

Try it

Good use of rate()? Swipe right for good.

Swipe right for good, left for needs work. Or use the buttons.

1 / 5rate(kedai_orders_total[5m])
rate(kedai_orders_total[5m])

Try it

increase() says how much a counter grew in the window. How many 500 errors in the last 10 minutes?

Filter code="500", add [10m], then wrap it all in increase( ). Run it.

Metrics in this data (tap to add):

Time 0 is when the data starts. The query looks back from the eval time.

Check

rate() says 0.25 per second. What does increase() say over [10m]?

Pick one answer.

You did it!

You can now turn a counter into a speed with rate() and a total with increase().

Go deeper (optional)

irate() uses only the last two samples: twitchy, good for fast graphs. Both guess the edges of the window. So increase() can show 133.33, not a whole number. In Grafana, $__rate_interval picks a safe window for you.

Real mission

  1. docker compose up -d
  2. docker compose down

0 of 4 steps done · Your ticks are saved.