Flux query to get sum of all records

Hi there,

I have just started using “flux” & I have read the docs & have no Idea why I am not able to get the expected sum of bytes from the further sample data:

device,ver=five,device=127.0.0.1 bytes=74u,packets=1u 1616949016000118000
device,ver=five,device=127.0.0.1 bytes=4592u,packets=29u 1616949016000118000
device,ver=five,device=127.0.0.1 bytes=90u,packets=1u 1616949016000118000
device,ver=five,device=127.0.0.1 bytes=697u,packets=11u 1616949016000118000
device,ver=five,device=192.168.0.1 bytes=7058u,packets=31u 1616949016000118000
device,ver=five,device=127.0.0.1 bytes=1277u,packets=13u 1616949016000118000

I just want to get sum of bytes group by ver tag. the query below returns “1277” which is the value of last series.

from(bucket: "the-bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "device")
  |> filter(fn: (r) => r["ver"] == "five")
  |> filter(fn: (r) => r["_field"] == "bytes")
  |> group(columns: ["ver"])
  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
  |> yield(name: "sum")

I really don’t know why I could not get this result. I would be thankful if someone advise me :wink:

I think the problem is my datatime stamp which I forgot to update it in protoline :wink: