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-.*"}
    
    1

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

    Variable Query

  4. Click Update.

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

ts{assetIds=[${variable:csv}]}
1

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.

Last Updated: 6/29/2020, 3:55:18 PM