I have the following flux query:
from(bucket: "testdb")
|> range(start:2022-07-21T09:57:49+02:00, stop:2022-07-21T09:58:49+02:00)
|> filter(fn: (r) => r["_measurement"] == "plantData")
|> filter(fn: (r) => r["_field"] == "Tonnes" )
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({ r with calc: r.Tonnes }))
|> aggregateWindow(every: 30s, fn: integral, column: "calc")
|> yield(name: "integral")
The reason for the “pivot” is I need to do calculation with multiple columns in case you were wondering.
My issue is the above gives timestamp results as follows:
- 09:58:30 - 09:58:49
- 09:58:00 - 09:58:30
- 09:57:30 - 09:58:00
The first datapoints is not a complete 30 second data point as Influx tries to create “even” brackets.
I need the results to look as follows:
- 09:58:19 - 09:58:49
- 09:57:49 - 09:58:19
- 09:57:19 - 09:57:49
Complete 30 second intervals.
Any idea how do modify the query ?