Integral function in FLuxQL

Hi,

I just migrate to Grafana 2.7 and now use fluxql instead of influx.

I have problem with my integration table. I use a light sensor calculating PPFD.

See image here:

IN left side you have light PPFD for each day. What I want in the right is the integration of each 24h time 00h00 to 23h59.
I must have 1 table line per day.

ANy hints how I can achieve this?

My actual flux query is this:
from(bucket: “borealis”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “borealis”)
|> filter(fn: (r) => r[“_field”] == “LIGHT”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)
|> integral(unit: 24h, column: “_value”)

OK I found the way but Now I have an other bug…

With this code I have the good integral. But I want to divide the value By 1000…
How I can do it?

from(bucket: “borealis”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “borealis”)
|> filter(fn: (r) => r[“_field”] == “LIGHT”)
|> aggregateWindow(every: 24h, fn: integral, createEmpty: false)

Welcome @fredericgag to the Grafana forum. Nice work on the integral solution.

Try adding a map function after the aggregateWindow function, like this:

|> map(fn: (r) => ({r with _value: r._value / 1000.0}))

Working thx!

1 Like