Chain variables together
Chained variables create dependent relationships where the options available in one variable depend on the selections made in another. This pattern enables cascading filters that help users drill down through hierarchical data structures.
Cascading filter patterns are common in multi-tier filtering scenarios such as region > cluster > namespace > pod. Each level narrows the available options based on the previous selection, creating an intuitive navigation experience through your infrastructure or data hierarchy.
To create chained variables, complete the following steps:
In the sidebar on the right side of the dashboard, click the Dashboard options icon.
In the edit pane that opens, click Settings.
On the Settings page, go to the Variables tab.
Create your first-level variable or parent variable.
For example, create a
regionvariable with querylabel_values(region).Click Save in top-right corner, enter an optional description of the changes, and Save again.
Click Back to list at the bottom of the page.
Click Add variable to create a second variable that depends on the first.
Name your dependent or child variable.
For example,
cluster.In the Query field, reference the parent variable to filter results.
For example, use
label_values(up{region="$region"}, cluster).Save the variable and then click Back to dashboard.
On the dashboard, test the cascading behavior by changing the parent variable selection.
The dependent variable options update automatically based on the parent selection.
Repeat the process to create additional levels of chained variables.
For example, create a
namespacevariable that depends oncluster.When you’ve finished your chain of variables, click Save.
(Optional) Enter a description of the changes you’ve made.
Click Save and Back to list at the bottom of the page.
Selecting a value in the parent variable updates the available options in dependent variables, creating a cascading filter experience.
In the next milestone, you learn how to configure variable display options to control how variables appear to your users.
At this point in your journey, you can explore the following paths:
