Variables will allow you to apply filters on your dashboards and drilldown links.

Follow these steps to add your dashboard variables:

Add dashboard variables

Before you begin, you’ll need: Metrics in your metrics account.

Add a new dashboard and variable
  • In the Metrics left menu, click .
  • Click in the dashboard toolbar (upper right corner).
  • Select Variables > Add variable.

Add Metrics interface variables

Define the variable

In this example, we will be focusing on the most common variable type - query variable. However, there are other variable types - you can see the complete list in the official documentation.

Fill in the form, starting with the General section.

  • Give a short variable Name. This is the placeholder value this variable will use.
  • Set a human-readable Label. This is the filter control at the top of your dashboard.
  • In the Type list, choose Query.
  • We recommend leaving Hide empty.

Variable general settings

Next, fill in the query options.

For the Data source, select your Metrics account. (You can look it up here.)

We recommend setting Refresh to automatically occur On Time Range change.

The Query field is where things get really fun. There are several options here, we will be focusing on the main ones (you can see the full list in the official documentation):

  • Getting label values with no specified conditions. For example: label_values(container).
  • Getting label values specified to a metric. The metric will come first, then the label’s name, separated by a comma. For example: label_values(container_cpu_usage_total,container).
  • Getting label values specified to a metric and a previous variable. The metric will come first, followed by the previous variable in curly brackets, then the label’s name, separated by a comma. For example: label_values(container_cpu_usage_total{cluster_name=~”$cluster”},container).

Query field preview

Configure the remaining options and save

You can set the remaining options to whatever makes the most sense for your metrics.

When finished, scroll to the bottom of the page and click Update.

You’re now ready to use the variable in your new dashboard.

Additional resources