BM: Baca dalam Bahasa Melayu
World O3: Alarms & Screens
Alert rules: for, labels, annotations
You will learn: to write an alert rule that rings only for real trouble.
Checked with Prometheus 3 on 1 Nov 2026
The problem
Press Run. Look at shop-1 on the graph.
At 11m, shop-1 stopped answering. Nobody was watching the screen. How can the control room ring a bell by itself?
Watch
Tap the line that says how long to wait.
0 of 1 found
An alert rule: A PromQL question Prometheus asks again and again. When the answer has rows, the control room's bell gets ready. is a question Prometheus asks every minute. Any rows in the answer? The bell gets ready.
Predict
db-1 was down for only 3 minutes. The rule waits for: 5m. What happens?
Pick one answer.
Try it
Build the rule. Page someone when a target is really down. Not for a short blip.
Build an alert rule from the blocks. The timeline shows when it would wait and when it would fire.
groups: - name: kedai rules: - alert: InstanceDown expr: up == 0 annotations: summary: Something is down
Graph as a table
| Time | up{instance="db-1", job="db"} | up{instance="shop-1", job="shop"} | up{instance="shop-2", job="shop"} |
|---|---|---|---|
| 0s | 1 | 1 | 1 |
| 1m | 1 | 1 | 1 |
| 2m | 1 | 1 | 1 |
| 3m | 1 | 1 | 1 |
| 4m | 1 | 1 | 1 |
| 5m | 1 | 1 | 1 |
| 6m | 0 | 1 | 1 |
| 7m | 0 | 1 | 1 |
| 8m | 0 | 1 | 1 |
| 9m | 1 | 1 | 1 |
| 10m | 1 | 1 | 1 |
| 11m | 1 | 0 | 1 |
| 12m | 1 | 0 | 1 |
| 13m | 1 | 0 | 1 |
| 14m | 1 | 0 | 1 |
| 15m | 1 | 0 | 1 |
| 16m | 1 | 0 | 1 |
| 17m | 1 | 0 | 1 |
| 18m | 1 | 0 | 1 |
| 19m | 1 | 0 | 1 |
| 20m | 1 | 0 | 1 |
| 21m | 1 | 0 | 1 |
| 22m | 1 | 0 | 1 |
| 23m | 1 | 0 | 1 |
| 24m | 1 | 0 | 1 |
| 25m | 1 | 0 | 1 |
| 26m | 1 | 0 | 1 |
| 27m | 1 | 0 | 1 |
| 28m | 1 | 0 | 1 |
| 29m | 1 | 0 | 1 |
| 30m | 1 | 0 | 1 |
| 31m | 1 | 0 | 1 |
What the alert does over time
Grey: quiet. Amber: pending (true, but waiting). Red: firing.
{instance="db-1", job="db"}๐ firing 6m to 8m
{instance="shop-1", job="shop"}๐ firing 11m to 31m
At 12m:
- FIRING
InstanceDowninstance="shop-1", job="shop"Something is down
Timeline as a table
| Time | {instance="db-1", job="db"} | {instance="shop-1", job="shop"} |
|---|---|---|
| 0s | quiet | quiet |
| 1m | quiet | quiet |
| 2m | quiet | quiet |
| 3m | quiet | quiet |
| 4m | quiet | quiet |
| 5m | quiet | quiet |
| 6m | ๐ firing | quiet |
| 7m | ๐ firing | quiet |
| 8m | ๐ firing | quiet |
| 9m | quiet | quiet |
| 10m | quiet | quiet |
| 11m | quiet | ๐ firing |
| 12m | quiet | ๐ firing |
| 13m | quiet | ๐ firing |
| 14m | quiet | ๐ firing |
| 15m | quiet | ๐ firing |
| 16m | quiet | ๐ firing |
| 17m | quiet | ๐ firing |
| 18m | quiet | ๐ firing |
| 19m | quiet | ๐ firing |
| 20m | quiet | ๐ firing |
| 21m | quiet | ๐ firing |
| 22m | quiet | ๐ firing |
| 23m | quiet | ๐ firing |
| 24m | quiet | ๐ firing |
| 25m | quiet | ๐ firing |
| 26m | quiet | ๐ firing |
| 27m | quiet | ๐ firing |
| 28m | quiet | ๐ firing |
| 29m | quiet | ๐ firing |
| 30m | quiet | ๐ firing |
| 31m | quiet | ๐ firing |
Hint
Amber โณ is pending: waiting. Red ๐ is firing: the bell rings.Check
Drag a card into a box. Or tap the card, then tap the box.
Labels steer the bell to the right person. Annotations are the note on it.
Check
promtool check rules tests the file before Prometheus loads it. The red line means: = is not a check. PromQL compares with ==.
You did it!
You can now write an alert rule that waits, then rings the right person.
Go deeper (optional)
keep_firing_for: 5m keeps the bell ringing a little after the problem ends. It stops on-off-on noise. In a message, {{ $labels.instance }} is the target and {{ $value }} is the number.
Real rep: run promtool from the official image. Your own laptop is fine.
Real mission
docker run --rm --entrypoint promtool -v "$PWD:/w" -w /w quay.io/prometheus/prometheus:v3.13.5 check rules rules.yml
0 of 3 steps done ยท Your ticks are saved.
Bahasa Melayu
Pada minit ke-11, shop-1 berhenti menjawab. Tiada siapa tengok skrin. Macam mana bilik kawalan boleh bunyikan loceng sendiri?
Alert rule (peraturan amaran) ialah soalan yang Prometheus tanya setiap minit. Ada baris dalam jawapan? Loceng bersedia.
db-1 mati selama 3 minit sahaja. Rule itu tunggu for: 5m. Apa jadi?
Bina rule itu. Panggil orang bila target betul-betul mati, bukan untuk kelip sekejap.
Label kemudi loceng ke orang yang betul. Anotasi ialah nota yang dilekat padanya.
promtool check rules uji fail itu sebelum Prometheus memuatkannya. Baris merah bermaksud: = bukan semakan. PromQL banding dengan ==.
Kini anda boleh tulis alert rule yang menunggu, kemudian panggil orang yang betul.
You finished this before. Practice is always welcome!
Official docs: Alerting rules ยท Template examples ยท promtool
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?