Using Grafana 8.5.3 with influxdb backend
I have a dashboard panel which does an influx query to sum a number of metrics - (eg Metric1 + metric2 + metric3 ) - call this A
This works and gives me a good result eg 45, 60, 55
What I have been asked to do is now do a conditional if then on that number using ranges to create a simple new value
eg if A is 0 then B is 0
If A is 01 to 30 then B is 50
If A is 30+ then B is 100
I’m looking at the potential of using an expression doing math but can’t seem to work out what we can do
It may be something very simple as this is a relative new model for me
So Ive been trying
Expression - Math
if {$A == 0 ] then B = 0
But this is quite obviously wrong
any tips or advice most welcome
Are you using Flux or InfluxQL?
Using influxQL
For a bit more info metric A (which works well) is based on
select last(“metric1”) + last(“metric2”) + .(up to 12) … as “total” FROM (SELECT max(“value”) AS “metric1” FROM “metric” WHERE (“type_instance” = ‘<type_instance1’ AND $timeFilter AND “host” =~ / / )fill(0)), (SELECT max(“value”) AS “metric2” FROM “metric” WHERE (“type_instance” = ‘<type_instance2’ AND $timeFilter AND “host” =~ / / )fill(0)), … GROUP BY time(10m)