To create a dynamic dashboard panels, template variables may be defined. Template variables appear to the user as drop downs or input boxes. The values selected by the user is then available to the creator in any field in the visual query builder.

Query

Basic Example

A TSDS query can be used to generate values for a template variable.

To create a query based template variable create a new template variable with type of Query. Set the Data source to tsds and then populate Query with a TSDS query that returns a single metric. Assuming the query is configured correctly the Preview will list an example of the returned values.

Search Template Variable

To create a search template variable create a mew template variable of type Text box and name it Search. The default value field under text options can be left empty. Next, create another template variable of type Query as shown in the basic example. Input the following query:

{"type": "search", "get": ["node"], "by": "node", "from": "interface", "fields": ["node"], "search": "$Search",  "order_by": "node", "limit": "100", "text": "", "value": ""}

Preview of values should show all the nodes from the query. Click save and go back to the dashboard. Inputting any search term in the search box will now show any matching results in the drop down list.

Adhoc filters

Adhoc filters can be added to a dashboard to allow the user to quickly filter results by any TSDS metric. Use the = operator for exact match, or the =~ operator when searching for partial matches.

To enable the adhoc filter menu, add a new template variable with a type of Ad hoc filters and a Name of interface.

Note: The Name must be interface.

Custom

Custom variables can be added to the dashboard which can also be used in any field of the visual query builder.

To add a custom variable, create a new variable of type Custom. Add comma separated values in the Custom Options section.

Note: There are other types of template variables like Interval, Datasource, Constant etc that can be created depending on the usecase and requirements of a dashboard.