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:

  1. In the sidebar on the right side of the dashboard, click the Dashboard options icon.

  2. In the edit pane that opens, click Settings.

  3. On the Settings page, go to the Variables tab.

  4. Create your first-level variable or parent variable.

    For example, create a region variable with query label_values(region).

  5. Click Save in top-right corner, enter an optional description of the changes, and Save again.

  6. Click Back to list at the bottom of the page.

  7. Click Add variable to create a second variable that depends on the first.

  8. Name your dependent or child variable.

    For example, cluster.

  9. In the Query field, reference the parent variable to filter results.

    For example, use label_values(up{region="$region"}, cluster).

  10. Save the variable and then click Back to dashboard.

  11. On the dashboard, test the cascading behavior by changing the parent variable selection.

    The dependent variable options update automatically based on the parent selection.

  12. Repeat the process to create additional levels of chained variables.

    For example, create a namespace variable that depends on cluster.

  13. When you’ve finished your chain of variables, click Save.

  14. (Optional) Enter a description of the changes you’ve made.

  15. 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.

More to explore (optional)

At this point in your journey, you can explore the following paths:

Chained variable examples


page 6 of 9