Default none/dummy option for template variables?

Enable the Include All option for a template variable automatically makes that the default value. This can make things unusable for some dashboards since too expensive to load. Saving the template values with the dashboard is an ok workaround, but still a bit klunky in that we have to select arbitrary values that may confuse future visitors. Plus, it breaks down when the variable is populated by a templated data source: changing the data source resets the dependent variables back to All which causes the browser to catch fire.

Has anyone found a more elegant workaround? Thanks!

1 Like

Did you figure this out? Iā€™m looking for a similar feature where it defaults to ā€œNoneā€. Iā€™d like a user to choose All or specific options.

Unfortunately, I was not able to find a good solution.

Iā€™m also looking for this feature. I will see if I can modify Grafana.

I also need the feature, that I can save my dashboard-variables with default value ā€œNoneā€ā€¦
Seems there is no option for this behaviour

I had the same issue. I have quite a hacky solution

In the grafana.dark..css and grafana.light..css files insert a line all at the beginning

@import utl('custom.css');

in the same folder as the grafana.dark/light css files, create a file named ā€˜custom.cssā€™ (without quotes of course) In that file, enter these css rules

a[aria-label="Dashboard template variables Variable Value DropDown value link text All"] span::after,
span[aria-label="Dashboard template variables Variable Value DropDown option text All"]::after {
    content: "None";
    visibility: visible;
    Margin-left: -16px;
}
a[aria-label="Dashboard template variables Variable Value DropDown value link text All"] span,
span[aria-label="Dashboard template variables Variable Value DropDown option text All"] {
    visibility: hidden;
}

Now in the variable of the dashboard, switch on the include all option, and set the custom all value to ā€˜ā€™ (two single quotes without any space) ā€¦ click update and save the dashboard.

I tested this on Grafana 7.1.1 and 8.0.6 and at my installation it shows ā€œNoneā€ instead of ā€œAllā€: and my query shows " point IN(ā€™ā€™) " when None is selected. I am using only the mssql datasources, but this may work with other datasources as well.

NOTE: this is a hacky solution and you need to modify the default css file(s). This may also break when the html structure is updated, or another build is installed (then the css files need modification again)

1 Like

Ha ha, that is quite a hack! I mean that in a positive way :clap:

1 Like

Please see:

Another alternative is to make grafana spit out the selected values separated by pipes:
... environment=~"${env:pipe}" ...
Doesnā€™t solve the ā€œnothing selectedā€ situation though :frowning:

Many thanks @barts2108
FYI if running Grafana in a Docker container, the path within the container to the grafana*.css files exists at something that looks like this (I am guessing it will not be the same exact path in all container instances):

/usr/share/grafana/public/build/grafana.light.f8ee15f0a88e16124678.css
/usr/share/grafana/public/build/grafana.dark.2336ef52b5298cb04209.css

Based on that information, can then using volume mappings to include custom.css