Zendesk template variables
Template variables let you build dynamic, reusable dashboards. Instead of hard-coding values such as a user or role into queries, you use variables that update from a drop-down at the top of the dashboard. For general information, refer to Templates and variables.
Before you begin
Before you use template variables, ensure you have configured the Zendesk data source.
Supported variable types
The Zendesk data source supports the following variable types:
Other standard Grafana variable types, such as Constant and Data source, also work with the data source. For more information, refer to Add and manage variables.
Create a query variable
A query variable populates its drop-down options from the result of a Zendesk query type. You choose which result field supplies the option values and which supplies the display labels.
- Navigate to your dashboard, then select Edit > Options > Variables.
- Select Add variable, then set Select variable type to Query.
- Enter a name for the variable, such as
user. - In the Data source field, select your Zendesk data source.
- Under Query options, select Open variable editor.
- Select an Action, such as Show all users, and set any required parameters.
- Set Value Field to the result field used as the variable value, such as
id. - Set Label Field to the result field shown in the drop-down, such as
name. - Confirm the preview of values, then select Apply.
Query variable examples
The following examples show common query variables. Set the variable type to Query and select your Zendesk data source for each.
When the Value Field and Label Field differ, the drop-down shows the label while queries receive the value. For example, a user variable can display user names while passing the user id to a query parameter. The Value Field and Label Field drop-downs list the fields returned by the query, so run the query once to populate them.
Use variables in queries
You can reference any dashboard variable in a Zendesk query parameter with the ${variable_name} syntax. For example, after you create the user query variable from the earlier example, reference it in the Users parameter of the Show selected users action as ${user}. The panel then follows the user selected in the dashboard drop-down.
You can also use variables in the Search query. For example, create a status variable of type Custom with the values open,pending,solved, then reference it in a search query as type:ticket status:${status} so the panel updates when you change the selected status.
To let viewers enter their own text, create a Text box variable, such as search_term, and reference it in a Search query as ${search_term}.
If a variable allows multiple values, the data source joins the selected values into a comma-separated list before sending them to the Zendesk API. For example, a multi-value user variable passes all the selected user IDs to the Users parameter of the Show selected users action.
Use cases
The following examples show common ways to use template variables with the Zendesk data source. Each row pairs a scenario with the variable type and configuration that supports it.


