Variables and templating

12 min
Audience
you have read lesson 01 and you know what legendFormat: "{{route}}" is
Duration
40 to 55 min
Module
4/7
Target skill
add a $route variable fed by label_values(...) to a dashboard, use it in queries with =~, choose between All, multi-value and single value, understand what $__rate_interval really replaces, and repeat a panel per value.

In one picture

Go back to lesson 01's cockpit. The kit's dashboard has 23 frozen dials: Trafic par route (Traffic per route) draws all routes at the same time. A variable (template variable) is a selector placed at the top of the cockpit: you choose /cours in the list, and all dials containing $route recompute for that route alone. Grafana does nothing magical: when sending the query to Prometheus, it replaces the text $route with the chosen value. The rest is PromQL you already know.

Preview — the rest of the lesson is for enrolled readers.

Already enrolled with a code?

Your access is tied to your account, not to this link. Sign in with the same email you used in class: your course is waiting, no need to enter the code again.

Sign inNo account yet? Create one
This lesson is part of the “Grafana: dashboards that answer a question” module

The first modules of the course are open to everyone. For the rest you have three options: buy this course once and for all, subscribe, or enter the code handed out in class.

Are you a student on this course?

The code is tied to your account: sign in or create an account and it will be applied automatically when you come back.

No account yet? Create one