- What Grafana version and what operating system are you using?
Running a Docker container from the grafana/grafana image, launched 6/28/23 so likely the most recent version.
- What are you trying to achieve?
I’m trying to sum several metrics into one total number. I have 5 power meters reporting their total energy usage for the month and I would like to sum those into one total power usage number.
- How are you trying to achieve it?
I can grab the usage numbers individually using the following query and a stat visualization, filtered by last* value:
from(bucket: "energy") |> range(start: v.timeRangeStart, stop:v.timeRangeStop) |> filter(fn: (r) => r._measurement == "s-31" and r._field == "totalwh" )
I would like a single stat that contains the sum of all 5 numbers.
I have tried using a math expression with Sum($A) (or sum or SUM), but it simply says ‘no data’.
I have tried using an ‘add field from calculation’ transform with reduce row, total, and selecting the 5 power usage fields, but it just displays the value of one of them.
- What happened?
- What did you expect to happen?
I would have expected either method to provide a summation of the last values of all 5 fields, or at least some form of a sum of something.
- Can you copy/paste the configuration(s) that you are having problems with?
The query is above, as is the math expression, I don’t know how to copy paste the transform, since it’s a gui configuration.
- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
The transform gives no errors, just nonsensical results. The math expression gives ‘no data’ with this error:
Query data error Object status:500 statusText:"" data:Object message:"Query data error" traceID:"" config:Object url:"api/ds/query?ds_type=__expr__&expression=true&requestId=Q279" method:"POST" data:Object requestId:"Q279" hideFromInspector:false headers:Object retry:0 traceId:undefined message:"Query error: 500 "
- Did you follow any online instructions? If so, what is the URL?
No, just general googling around and experimenting with the interface.
If there’s anything else I can add please let me know, I’m very new to grafana.
Edit: Basically I have this setup:
and what I’m looking for is a single stat that is the sum of all 5 of those values (2.05+5.4+1.72+0.165+0.863 = 10.198)