Skip to main content

Dashboard Variables

Dashboard variables allow you to create interactive, dynamic dashboards. They can be used in queries and panel titles to create dashboards that can be easily modified to show different data.

Create a Variable

To add a variable to your dashboard:

  1. Click the Edit button in the top-right corner of the dashboard. Edit dashboard button
  2. Click the Settings button that just appeared. Dashboard settings button
  3. The Settings page shows up. Dashboard settings variables
    1. Choose the Variables tab.
    2. This page has link to the detailed documentation for variables if needed.
    3. Click Add variable button.

In the next section we'll take a deeper look at some of the most useful and commonly used variable types.

Types of Variables

Oodle supports all the variable types supported by Grafana. Among those, two most useful and commonly used are Query, and Ad hoc filters.

While the Grafana docs cover the technical details, here we'll focus on how to configure them, and how to use them in dashboards.

Query Variable

Query variables are variables that show up as a dropdown in the dashboard, where the values shown in the dropdown are determined by running a PromQL query.

Let's look at the namespace variable in the Kubernetes / Views / Namespaces dashboard on Oodle Playground.

Appearance

This variable appears as a dropdown in the dashboard, where you can select the kubernetes namespace.

Dashboard variable namespace

Configuration

Here's how the configuration page for namespace looks like:

Dashboard variable namespace configuration
  1. Name specifies the name that will be used in the dashboard to reference the variable.
  2. Query is used to fetch the variable values, which will be displayed in the dropdown. In this example, it means:
    1. Query the metric kube_pod_info
    2. Only consider the timeseries where cluster label equals the value of cluster variable. Note how configuration of namespace variable makes use of another variable, cluster. Also note how $cluster is used to reference the cluster variable.
    3. From the resulting timeseries, take the value of namespace label.
    4. Take the distinct set of values from the namespace label, and populate the dropdown.
  3. Multi-value allows to select multiple values from the dropdown.
  4. Include All option allows to include the special "All" value in the dropdown.
  5. Preview of values shows all the values that will be present in the dropdown.

Usage

The Kubernetes Resource Count panel uses the namespace variable by adding $namespace appropriately in all the queries of the panel that need to filter by namespace:

Dashboard variable namespace usage

Ad-hoc Filters

Appearance

Ad-hoc filters show up as double-dropdowns in the dashboard, where you can select:

  1. The PromQL label to filter by
  2. The value of the label to filter by
Dashboard variable namespace usage

Configuration

Ad-hoc filters are configured by choosing Ad-hoc filters in "Select variable type" dropdown.

Dashboard variable namespace usage

Usage

Unlike query variables, which need to be referenced in the query using $variable_name, ad-hoc filters don't need to be referenced in the query at all. Instead, they are automatically applied to all the queries in the dashboard.

Support

If you have any questions or need any assistance, please contact us via our help chat app located at the bottom-right of the page or by reaching out to support@oodle.ai.