3

I'm using Grafana with Prometheus as a Datasource.

I'm trying to create a variable with a filtered list of servers and I want to use this list to fix list of servers to display in my Dashboard.

My variable, named servers_front, is a query (label_values(info_fqdn)) with a regex to choose my servers /.*_front/

I want to use this full list of servers by default without displaying a combobox to choose which one I want to display.

Another requirement : If a new server that matches /.*_front/ is created, I want the list is automatically updated

2 Answers 2

6

Edit the variable Variables > Edit > Selection Options >enable Include All option >Custom all value>.* enter image description here

1

When saving dashboard you have an option to "save current variables", which means that currently selected value will be stored as a default when dashboard is loaded. So if you have a templating variable with enabled "All" option you can save your dashboard ensuring "All" is selected (with option mentioned above enabled) and it should work.

Note that what is stored in dashboard is real "all" option and not an expanded list of all currently present values, so it should be dynamically expanded.

If you want that variable hidden then either you can hide the variable and save again after changing and saving its value or (if you have variable hidden from the start you can open url for dashboard with "&var-servers_front=All" appended (which will force variable to have "All" value and save dashboard with "save current variables".

2
  • I'll complete my question : with your solution the list is fixed. If a new server that match /.*_front/ is created, I have to unhide all variables, select new server, hide again for all dashboards
    – Nelson G.
    Commented May 16, 2019 at 11:16
  • Do you have Refresh set to "on dashboard load" or "on time range change" in the variable settings?
    – bjakubski
    Commented May 17, 2019 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.