Template variables
Template variables
One dashboard, every service — without duplicating it.
A variable is a placeholder the viewer picks from a dropdown. Reference it in LSQL with $name.
Definition
{
"variables": [
{
"name": "service",
"type": "query",
"apl": "['api-gateway-prod'] | distinct service | order by service asc",
"multi": true,
"default": ["checkout"]
},
{
"name": "env",
"type": "static",
"options": ["production", "staging"],
"default": ["production"]
}
]
}Using them
read top to bottom
1['api-gateway-prod']2| where service in ($service) and environment == $env3| summarize p95 = percentile(latency, 95) by bin_auto(_time), service4| order by _time asc| Type | Options come from |
|---|---|
query | An LSQL query, refreshed with the dashboard |
static | A fixed list you provide |
textbox | Free text the viewer types |
interval | Time steps, for use in bin($interval) |
Multi-select needs in, not ==
multi: true renders $service as a list, so service == $service breaks the moment someone picks two. Always write service in ($service) for a multi variable.