influxdata / influxdata/influxdb
Compare consecutive values of the same field with InfluxDB
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
Hi all, I have a question regarding a query for InfluxDB using the query-language flux. I have a measurement with two relevant fields, both of the type float. I managed to calculate a mean value for field_1 for a specific time range with the aggregateWindow function. now I need to add a condition to the statement, where I look at field_2 and exclude all values from the aggregation, where field_2 changed it's own value. so, given this example:
`time field_1 field_2`
`12:00:01 1.15 2.0`
`12:00:02 1.24 2.0`
`12:00:03 2.45 2.5`
`12:00:04 0.98 2.5`
I would like to exclude the third value from the aggregation (which would be in this case field_1: 2.45), because field_2 changed its value (from 2.0 to 2.5). I found the function difference(last(value)) which could give me the difference for two consecutive values. but I haven't found a way to use "difference" as a condition in a query, so I'm not sure if this is the right way to go. is there any way to do what I'm looking for here?
Contributor guide
Research direction
The issue names Flux's aggregateWindow and difference(last(value)) functions; start by tracing how consecutive field_2 values and filters are represented in the Flux query language. Done would be a documented or tested way to exclude the row where field_2 changes, but no repository file or test is identified.
Written by the indexing model from the issue text.
Assessment
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100