Join all values of a custom variable with a InfluxDB query

Hi All,

I am using Influx DB & Grafana and we pass some custom data into influx DB which are monitored in Grafana. Can you please help me with this scenario -

I have a custom variable $var with values ABC, XYZ, KLM (Selected → ALL option)
I have created a Table panel in Grafana that queries influxdb using query and displays as a table -

SELECT sum(“value”) FROM “one_month”.“table_name” WHERE (“status” = ‘stopped’ AND “server” = $var) AND $timeFilter GROUP BY “server”

which returns -

ABC | 67
XYZ | 81

The entry for server = KLM is not there in “one_month”.“table_name” so it does not show in this result.

Is it possible to somehow return data (value | 0 ) for all my custom variables even if that is not present in Influx DB.

For above query I would expect the result as -

ABC | 67
XYZ | 81
KLM | 0

Original requirement was like -

For each value in variable : -

Display the value of the variable & some number queried from influxdb

Any ideas please?

Thanks

Welcome!

hard to say and test locally without sample data but maybe this? you probably would have to do some sort of left join so that where there is no match you can still get results back and do some more transformations

could you please provide sample data as csv?

datetime,kwh
2022-04-26 11:15:30,14.7
2022-04-26 11:30:30,11.7
2022-04-26 11:45:30,23.7
2022-04-27 11:15:30,21.7
2022-04-28 11:15:30,22.7
2022-04-29 11:15:30,0.7
2022-04-30 11:15:30,4.7
2022-05-01 11:15:30,7.7
2022-05-02 11:15:30,41.7
2022-05-03 11:15:30,55.7
2022-05-04 11:15:30,4.7

And also what kind of visualization will you be using?