Dashboard variables

By configuring variables for a dashboard, you can create dashboards with dynamic widgets. Variables enable the reuse of a single dashboard definition for different use-cases.

Viewing dashboard variables

In the top navigation bar, use the dropdown menu next to the "Save…​" button, and click "Edit dashboard variables".

Built-in variables

There are variables that are built-in to SUSE® Observability. The names of these variables are reserved, and you cannot give your own variables the same names.

To view all built-in variables, click the accordion titled "SUSE Observability PromQL variables".

Adding a new variable

  1. Open the "Edit dashboard variables" drawer.

  2. Click the "Add variable" button to open a second drawer where you can configure the new variable.

The configuration fields for a variable are as follows:

Field name Description

Name

The name identifier of the variable. This is the name that you can use in compatible fields.

Display label

A friendly name for the variable that is shown on the dashboard when selecting the variable. This helps you identify the variable.

Description

A description to understand the purpose for the variable. This description is shown in the "Edit dashboard variables" drawer.

Type

The type of the variable.

Variable types

Text variable

A text variable contains simple text. You can set an initial value and make the variable read-only.

List variable

A list variable has possible values which are defined by the "Source" field. Each source type provides additional fields which allow you to narrow down the possible values for the variable.

Source type Source fields

Metric label names

Enter zero or more series selectors to refine which metric label names are present.

Metric label values

Enter a metric label name, and zero or more series selectors to refine which metric label values are present.

Metric PromQL

Enter a custom PromQL query, and a label name. The resulting possible values are the values for the given label name.

Static list

Enter one or more label and value pairs to construct a static list of possible values.

As you change the source type and their related fields, the preview on the right-hand-side of the drawer will update with the new possible values.

Common list variable settings

All list variable sources also have the following common settings:

Field name Description

Sort

Sort the values in the list. For example, alphabetically or numerically.

Allow multiple values

Allow users to select more than one value at a time.

Enable "Include Everything"

Adds an item to select all values to the list that the user sees. You can optionally specify a custom value for this item, or let it be automatically generated.

Using variables

Once a variable is defined, it can be used to populate various fields in the dashboard:

  • Other variables

  • Widget name and description

  • Widget link fields: URL, Name, and Tooltip

  • Widget query fields: PromQL Expression, Alias, and Min Step

  • Markdown widget’s editor

To use a variable in a compatible field, use the variable name wrapped in ${} (for example, ${my_variable}). The value of the variable is interpolated.

How variables are interpolated

Text variables are interpolated as the string that is written in the textbox of the variable.

Similarly, list variables that do not allow multiple values nor "Include Everything" are interpolated as the value of the selected item from the list.

List variables that allow multiple values are interpolated as a regular expression capturing group of the selected values (for example (value_1|value_2)) regardless of whether one or multiple options are selected.

List variables that have the "Include Everything" option enabled and selected for that variable will either interpolate as: * The custom value if defined, or * A generated regular expression capturing group of all possible values (for example (value_1|value_2|value_3))

You can use the PromQL regular expression matcher =~ when consuming variables that are interpolated as regular expression capturing groups.

Selecting variables

Variables are listed towards the top of the dashboard, next to the time range selector. Only the first few variables are shown. To see the rest of the variables, use the "More" dropdown.

Click a variable to open its selector and select the values you wish to show on the dashboard.

As you select different values, the widgets using the variable will react to the changes.