BM: Baca dalam Bahasa Melayu
World O3: Alarms & Screens
Variables and templating
You will learn: to make one dashboard serve every shop with a drop-down.
Checked with Prometheus 3 on 1 Nov 2026
The problem
Kedai Kancil has two shop servers, and soon five. Do you build one dashboard per shop?
Pick one answer.
Watch
You picked shop-1 and shop-2. Grafana swaps $instance before Prometheus sees it. Write what Prometheus gets.
Type a PromQL query and press Run. The table shows the answer at the eval time. The graph shows it over time.
A dashboard variable: A drop-down at the top of a Grafana dashboard. Pick shop-2 and every panel's query swaps $instance for shop-2. is that drop-down. Every panel reads it.
Try it
Build a panel query that follows the drop-down. Tap the pieces in order.
Tap the pieces in the right order.
Hint
=~ matches a pattern. Two picked shops become shop-1|shop-2.Predict
Two shops are picked. A panel says instance="$instance", with one =. What does it show?
Pick one answer.
Check
Drag a card into a box. Or tap the card, then tap the box.
$__rate_interval only works inside Grafana. Rules run in Prometheus, so they use a fixed window.
You did it!
You can now make one dashboard serve every shop with a variable.
Go deeper (optional)
Make the variable a Query variable: type Label values, label instance, metric up. Turn on Multi-value and Include All. Variables can chain: pick a job, and the instance list shrinks to match.
Real mission
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
Kedai Kancil ada dua server kedai, dan tak lama lagi lima. Perlukah satu dashboard untuk setiap kedai?
Anda pilih shop-1 dan shop-2. Grafana tukar $instance sebelum Prometheus nampak. Tulis apa yang Prometheus terima.
Dashboard variable ialah senarai pilihan itu. Setiap panel membacanya.
Bina query panel yang ikut senarai pilihan. Ketik kepingan mengikut urutan.
=~ padankan corak. Dua kedai yang dipilih jadi shop-1|shop-2.Dua kedai dipilih. Satu panel tulis instance="$instance", dengan satu =. Apa ia tunjuk?
$__rate_interval cuma berfungsi dalam Grafana. Rule berjalan dalam Prometheus, jadi ia guna tetingkap tetap.
Kini anda boleh jadikan satu dashboard melayan setiap kedai dengan variable.
You finished this before. Practice is always welcome!
Official docs: Grafana variables · Prometheus template variables
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?