Dashboard query variable with no default

  • What Grafana version and what operating system are you using?
    Grafana Cloud

  • What are you trying to achieve?
    I have a dashboard query variable whose values come from a prometheus query label values. The values from this query change often, and I want the default value to always be the first one alphabetically.

  • How are you trying to achieve it?
    Looking through all the variable options, I see how to choose a specific default value, but I can’t find a way to remove the default. The best workaround I found is to add a custom value called “select” as the default, which makes all the panels not load, forcing the user to change it.

For context: This dashboard is used to visualize cinema projector measurements taken once per day, and scraped by prometheus every minute. All metrics are labeled with the measurement date, which is different than the prometheus timestamp, so the user needs to be able to select which measurement to view. Some panels draw a time series to see it over time, and other panels show one specific measurement based on that variable.

Can you do an All option?

or provide your own value for All

The ‘all’ option is essentially the same as a custom option. The user still has to change the variable to the first real value before the panels will load.

oh gotcha. so whatever the variable query returns you want the first one (sorted asc) to be auto selected?

right!

1 Like

Edit dashboard json model manually and remove default value in the variable definition. Don’t save variable default then when you will be saving dashboard. Make sure variable values are sorted alphabetically.

1 Like

I tried that, but it adds it right back when I save.

File this as a bug :bug:

Grafana is asking if you want to save default variables values - just don’t check that checkbox.

Actually I tried again, editing the JSON and this time it worked!