Fill function not working
I have a measurement being updated every 9 minutes. I have tried using the fill function to replicate the IFQL fill(previous) behavior but it doesn't seem create the data specified by the window.
Expected: start and stop should be for every minute in the range (not just a minute when there is a value stored) with the value using the previous value if missing.
Flux script tested on 2.0 Alpha1:
from(bucket: "test")
|> range(start: -1d )
|> filter({filter removed})
|> window(every: 1m)
|> fill(usePrevious:true)
|> last()
I have a scenario like this.
I want to sum the points of both (or more) symbols each 20 seconds (or any other interval). Below are the raw points stored in a single measurement grouped by symbol. The second query is the one I came up with to calculate sum(sum() gives me same issue as well).
select last(bs) from table where symbol=<1> or symbol=<2> and time>=1592833320000ms and time<=1592833440000ms group by symbol, time(20s)
name: table tags: symbol=<1> time last
2020-06-22T13:42:00Z 84 2020-06-22T13:42:20Z 94 2020-06-22T13:42:40Z 95 2020-06-22T13:43:00Z 87 2020-06-22T13:43:20Z 76 2020-06-22T13:43:40Z 77 2020-06-22T13:44:00Z
name: table tags: symbol=<2> time last
2020-06-22T13:42:00Z 288 2020-06-22T13:42:20Z 286 2020-06-22T13:42:40Z 282 2020-06-22T13:43:00Z 2020-06-22T13:43:20Z 312 2020-06-22T13:43:40Z 330 2020-06-22T13:44:00Z
check out how 13:43:00Z has no value; fill(previous) works if this was a single query and will copy over 282 from above. But when I group by both symbols the value will just be 0 for this time stamp and the mean value will go way down at this time.
select mean(lbs) from (select last(bs) as lbs from table where symbol=<1> or symbol=<2> and time>=1592833320000ms and time<=1592833440000ms group by symbol, time(20s)) group by time(20s) limit 10 name: table time mean
2020-06-22T13:42:00Z 372 2020-06-22T13:42:20Z 380 2020-06-22T13:42:40Z 377 2020-06-22T13:43:00Z 87 2020-06-22T13:43:20Z 388 2020-06-22T13:43:40Z 407 2020-06-22T13:44:00Z
Having a fill(previous) in the inner query does not work. Question is, how can I take the last value of the missing groups into the mean calculation.
I even tried using FLUX with the following query, but still see same issue. from(bucket: "db/rp") |> range($range) |> filter(fn: (r) => r._measurement == "table" and (r._field == "") and r.symbol=~ /^[[Symbol]]$/) |> aggregateWindow(every: 1m, createEmpty: true, fn:sum) |> fill(usePrevious: true) |> group(columns: ["_time", "_field"]) |> sum() |> group(columns: ["_measurement", "_field"])
Let me know if there is any workaround for this issue. Thanks!
This issue has had no recent activity and will be closed soon.