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.
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.
Try it
Good use of rate()? Swipe right for good.
Swipe right for good, left for needs work. Or use the buttons.
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.
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
docker compose up -ddocker compose down
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Counter nasi lemak di SS15 tunjuk 300. Adakah gerai itu sibuk sekarang?
rate() beritahu berapa laju counter naik, sesaat, dalam satu tetingkap.
Nasi lemak di SS15 naik 0, 30, 60, 90… satu langkah setiap minit. Apa kata rate()?
Mula semula akan reset counter ke 0. rate() perasan penurunan itu dan terus mengira naik.
Guna rate() dengan betul? Leret ke kanan untuk yang baik.
increase() kata berapa banyak counter naik dalam tetingkap. Berapa ralat 500 dalam 10 minit lepas?
rate() kata 0.25 sesaat. Apa kata increase() untuk [10m]?
Kini anda boleh tukar counter jadi kelajuan dengan rate() dan jumlah dengan increase().
You finished this before. Practice is always welcome!
Official docs: PromQL functions: rate() · PromQL functions: increase() · Prometheus: metric types (counter)
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?