I have a Prometheus server gathering metrics from several software installations. Each installation applies labels "Customer" & "System" to all metrics in the Prometheus relabel phase, and I have a Grafana dashboard which uses template variables $Customer, $System so my dashboard shows graphs for a single customer-system.
e.g. I can choose "Google/Test" or "Microsoft/Live" combinations.
This means all my queries are like my_counter_total{Customer='$Customer', System='$System'} which is rather tiring. Is there anyway to apply {Customer='$Customer', System='$System'} at dashboard level to all queries? The Grafana documentation hints it can be done but doesn't say how, and I cannot find a single example.
edit: As noted 'ad hoc queries' seem to be able to do this but the entire documentation is:
Ad hoc filters are one of the most complex and flexible variable options available. Instead of a regular list of variable options, this variable allows you to build a dashboard-wide ad hoc query. Filters you apply in this manner are applied to all panels on the dashboard.
So they tell me it's very complicated and leave me hanging :)
You can do that using an "Ad hoc filter" variable.
Go to Dashboard settings > Variables > New
Fill the options like the following example and click on Add



Note: The "mountpoint=/home/cds/tool/bitbucket" will automatically be used for all query expressions of all panes in the dashboard.
See more details in Grafana documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With