What are Grafana template variables and why use them?
⚡
Quick Answer
Variables turn one dashboard into many by injecting selectable values (like $service) into every panel query.
Detailed Answer
A Query variable pulls live values from a data source (e.g. label_values(http_requests_total, service)); Custom, Interval, and Data source types also exist. Reference them in queries with $var and enable Multi-value/Include All for filtering. One well-templated dashboard replaces dozens of near-duplicates and lets viewers slice by service, namespace, or environment.
Code Example
label_values(http_requests_total, service)
💡
Interview Tip
Show label_values() for Prometheus and mention the 'Data source' variable to switch prod/staging.
grafanavariablestemplating