Skip to main content

Dashboard Variables

Dashboard variables allow you to apply filters and drill-down links to your dashboards.

Prerequisites: You need to enable Metrics in your Logz.io account.

Add a new dashboard and variable

Navigate to your Metrics dashboard, click the cogwheel icon in the upper right corner of the dashboard toolbar, and select Variables > New.

Define the variable

In this example, we'll focus on the most common variable type — query variable. Other variable types are available in the official documentation.

General settings:

  • Name: Provide a short placeholder value for the variable
  • Label: Set a human-readable label for the filter control at the top of your dashboard
  • Type: Choose Query
  • We recommend leaving Hide empty checked

Enabling the Hide option for a variable in Grafana removes it from the dashboard's variable dropdown menu, streamlining the user interface while still allowing the variable to function in queries and dashboard settings. This keeps the dashboard clean and focused by concealing unnecessary variables from users without affecting their underlying functionality. Read more about variables in Grafana.

//Variable general settings

Query options:

  • Data Source: Select your Metrics account. (You can look it up here)

  • Refresh: The recommended setting is to automatically occur On Time Range Change

  • Query Field: Enter your query. The full list is available in Grafana's official documentation. Here are some common examples:

    • Getting label values with no specified conditions. For example, label_values(container)
    • Getting label values for a specific 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 for a specific metric and 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

Query field preview:

Configure the remaining options as needed for your metrics.

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

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

Additional resources: