influxdata/flux

Unable to aggregate data after calculation

MatinF opened this issue · 1 comments

I am trying to calculate the delta between an Epoch parameter and the 'timestamp' (in Epoch form) of the same parameter. I am doing this in Grafana via InfluxDB Flux. My query below produces a signal, RTC, that gives the correct value:

from(bucket: "new-test-bucket-2")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => contains(value: r["_measurement"], set: ${devices:json}))
  |> filter(fn: (r) => r["_field"] == "Epoch")
  |> map(fn: (r) => ({r with RTCminusEpoch: (float(v: r._time)/1000000000.0 - float(v: r._value))} ))

image

The problem (as shown by the red warning) is that I need to aggregate this before sending it to Grafana - otherwise I get a #datapoints issue. However, I cannot aggregate the query before the "map" part as it will result in incorrect delta values. Instead, I need to somehow aggregate the result after it has been calculated on the InfluxDB side.

This issue has had no recent activity and will be closed soon.