Present the original value and its 5 minutes difference value in one diagram

  • What Grafana version and what operating system are you using?
    Grafana 9.3.1 on Linux Debian GNU/Linux 10 (buster) using InfluxDB2 data

  • What are you trying to achieve?
    I want two curves in one diagram. One with absolute data (growing water usage values) and the second with the difference values of 5 minutes iterations

  • How are you trying to achieve it?
    Flux language - script

  • What did you expect to happen?
    two curves with two y-axes and different scales

  • Can you copy/paste the configuration(s) that you are having problems with?
    two diagrams a) and b) I want to have in one.

a)
from(bucket: “SmartHome”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “watermeter.verbrauch”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)

b)
from(bucket: “SmartHome”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “watermeter.verbrauch”)
|> filter(fn: (r) => r._field == “value”)
|> difference()
|> aggregateWindow(every: 5m, fn: sum)

Thank you

Welcome @gnomi

Have you tried using an override, like this? This would put query B on the right y-axis.

Thank you @grant2

this was also my idea, but I am missing the second field.
I just started with Flux and Grafana. In my examples it is always the same field:
watermeter.verbrauch → value
One with the added funnction difference.
And in the overrides I can only address different fields.
So I have to create your 5-minute-difference field, so that I can address it in the overrides.
Here I have a blocking, if I can create variables or …?

UPDATE:
Found it: I separated the two queries (A+B) (before I had in one window)

and then I could select with “Fields returned by query”

Thanks

1 Like