Making multiple queries on the same panel with the help of template variables

Hello everyone,

I am very fond of templating feature on grafana and i use it extensively. The current way i am using it is by adding the variable name like $var in my sql or psql query and along with that replicating the panel by repeating the panel with the same variable. (Genearl - Repeat - For each value of). So by selecting multiple values of that $var, it creates that many panels.

But i want to use it in this way that whenever i select multiple values of $var, instead of creating multiple panels, it should create multiple queries by just replacing the value. Either by creating a new query say ‘B’ inside the panel itself.
I am new here, so does a way to do that on psql and sql queries exists already because i want to achieve that on my graph panel where i can plot the values and trend for two days on the same graph itself.

3 Likes

Did you find any solution? i am also looking something similar.

1 Like

any updates about this feature ?

For those still looking for an answer:

We have success (Grafana 8.5.2) with a MySQL-query like
select datetime_ as "time", value_ as "", name_ from tmp;
resulting in rows like
|2022-07-13 00:00:00|37.0000|c01|
|2022-07-13 00:00:00|37.0000|c01|
|2022-07-13 00:00:00|37.0000|c01|
|2022-07-07 00:00:00|2510.0000|c02|
|2022-07-07 00:00:00|2510.0000|c02|
|2022-07-07 00:00:00|2510.0000|c02|
|2022-07-07 00:00:00|2510.0000|c02|

The panel then shows datetime-graphs with values ‘value_’ for every ‘name_’
testgraph