Create custom variables
Custom variables use manually defined option lists rather than querying data sources, making them ideal for static values that don’t change frequently or don’t exist in your data. They’re perfect for cases where you want to present specific choices to users without depending on query results. They also offer predictability and control when the available options should remain consistent regardless of what data exists in your data sources.
While query-based variables are excellent for discovering dynamic infrastructure, custom variables provide control over exact options and ordering for business logic that exists outside your monitoring data.
To create a custom variable, complete the following steps:
Open your dashboard, click Edit, then go to Dashboard options > Settings and click the Variables tab.
On the Variables tab, click Add variable.
In the Variable type drop-down list, choose Custom.
In the General section, enter the name of the variable. This is the name that you’ll use later in queries.
For example,
severity.In the Custom options section, enter the values for this variable in a comma-separated list.
For example,
critical,warning,info,debug.In the Preview of values section, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.
Click Save.
(Optional) Enter a description of the changes you’ve made.
Click Save and Back to dashboard.
The dashboard displays the custom variable at the top as a drop-down list with your defined options.
In the next milestone, you learn how to reference variables in panel queries to filter data based on user selections.
