简体   繁体   中英

Modifying the series data using flux language in influx

I have a function which takes the 1st value from a masurement every 5mins.

ever5Mins1st = from(bucket: "Historian/oneday")
  |> range(start: dashboardTime)
  |> filter(fn: (r) => 
    r._measurement == "InventoryStock" and
    r._field =="Value"  and
    r.Location=="NYC"
  )
 |>window(every:5m)
 |>first()
 |>window(every:inf)

Now If I want to do a difference of two consecutive points , I can do by using difference function

 ever5Mins1st
 |>difference()

But what If I do I want a sum of every consecutive points or every 5 points.

I know I can write custom functions which recieves piped data. But do I need to write a for loop? Are there any examples of for loops and conditional statements?

// Function definition
add = (tables=<-) =>
  tables
    |> map(fn: (r) => //What should I do here, for loop?)

I don't believe this is possible at the moment. This would require a chunk function, to split a list into chunks of lists.

I'll add an issue to Flux and start to implement this functionality :+1:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM