I'm trying to show/hide queries on the graph panel depending on the dashboard variable values.
Motivation.
On the same graph panel (which is used to display several hosts) I have two queries:
rate(ClickHouseProfileEvents_Query{instance=~"$instance"}[$__rate_interval])
And:
max_over_time( (irate(ClickHouseProfileEvents_Query{instance=~"$instance"}[2m]))[$__rate_interval:15s] )
Where ClickHouseProfileEvents_Query
is a counter.
The first one is a usual rate that is better for showing trends, and the other one is a little more complex but shows all picks. Of course, I would like to make one panel for the graph but also have some switches like trends/picks to analyze both. I've introduced a grafana dashboard variable with custom values, but I can't understand how I can use it to hide or show a particular query.
Also, I tried to make a single query using things like or
or unless
but unsuccessfully.
Environment: Grafana v7.5.2, Prometheus v2.26.0
UPDATE:
Thanks to Marcelo Ávila de Oliveira for answer. My current solution is a little bit different but based on his idea.
First, I add type Custom
variables with values 1
and null.
Second, I use multiply instead of division in my queries.
And finally, as a result, when I turn off, for example, trends showing, I'm not seeing them both in graph and the legend too.