Hello there !
Working on translating InfluxQL to Flux on Grafana, I’ve seen that the Flux derivative
function does not seems to work like the InfluxQL non_negative_derivative
concerning timestamp. In fact, when doing the derivative between values at time A (older) and time B, InfluxQL returns the value with timestamp A whereas Flux returns it with timestamp B
(Top graph is the InfluxQL query, bottom one is the Flux query)
The values I’m working on are returned by Telegraf, and in the early seconds of a minute the last value is way higher with Flux than with InfluxQL, and I sometimes get really high peak that decreases with time
Is there a way to solve this ?
For info:
InfluxQL query:
SELECT non_negative_derivative(mean("FIELD"), 1s) FROM "MEASUREMENT" WHERE ("VARIABLE" =~ /^$VARIABLE$/) AND $timeFilter GROUP BY time($__interval) fill(null)
Flux query:
from(bucket: "BUCKET")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "MEASUREMENT")
|> filter(fn: (r) => r["_field"] == "FIELD")
|> filter(fn: (r) => r["VARIABLE"] =~ /^${VARIABLE:regex}$/)
|> set(key: "alias", value: "TPS")
|> group(columns: ["alias"])
|> aggregateWindow(every: v.windowPeriod, fn: mean)
|> derivative(unit: 1s, nonNegative: true)