Skip to main content

Create templates with global variables

To create templates to build interactive dashboards you can use variables via the $variable or [[variable]] syntax. You can learn more about templates and variables in the Grafana documentation.

To add variables for assets to a dashboard in Grafana:

  1. Navigate to your dashboard's settings, and then select Variables from the left side.

  2. Make sure the Type is set to Query, and then set your Cognite Data Source as the Data Source.

  3. Specify the query to fetch and filter assets from CDF. For example:

    assets{parentIds=[123], name=~"test-.*"}

    The query above requests assets with the parameter parentIds=[123] and filters the results by name that matches the test-.* regular expression.

  4. Click Update.

You can format variables to fit into the query, for instance if you have a multi-value variable:


The variable will be serialized to comma-separated values in case several assets are selected from the dropdown. Learn more about formatting of variables in the Grafana documentation.

Nested (chained) variables

With nested variables, you can create a template to visualize time series related to a branch of the asset subtree and let users navigate the subtree.

  1. Create the necessary nested variables.

    Link variables
  2. Use the variable as the asset filter on the dashboard.

    Use the variable on the dashboard
  3. On the dashboard, users can choose assets on each level of the hierarchy.

    Select assets from the dropdown