Skip to main content

Create templates with global variables

Use variables to create templates using the $variable or [[variable]] syntax.

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

  2. Set Type to Query, and select your Cognite Data Source as the Data source.

  3. In the Query field, enter the query to fetch and filter assets from CDF.

    For example, this query requests assets with the parameter parentIds=[123] and filters the results by name that matches the test-.* regular expression:

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

    For a list of valid parameters, see the API documentation.

    Also, see this article to learn how to filter the results.

    You can format variables to fit into the query, for instance, if you have a multi-value variable like ts{assetIds=[${variable:csv}]}.

    If you select several assets from the dropdown, the variable is serialized to comma-separated values. Learn more about the variable format options in the Grafana documentation.

  4. Select Update.

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. Users can choose assets on each level of the hierarchy.

    Select assets from the dropdown