I am pretty new to InfluxDB. I have an application that collects data with 20kHz, which is written to the database.
At some point I need to query/show this data. Currently I achieve this with:
from(bucket: "test-bucket")
|> range(start: 0; stop: now())
|> filter(fn: (r) => r["_field"] == "sensorValue")
|> aggregateWindow(every: 1s, fn: mean, createEmpty: false
|> yield(name: "mean")
The problem I do have is the mean function. I do have data, which might jump up and down quite fast. So calculating the mean value of each window is not good for me here, because it smoothes the data to much.
What I want to achieve is to get the min and max value (and its corresponding timestamp) from every window.
For example if the 'window' has the following data:
value: 10 11 10 12 13 27 10 2 10 11
time: 0 1 2 3 4 5 6 7 8 9
I want to get for max (27, 5) and for min (2,7). Is there any function doing this? Or even better, is there any other downsampling function that keeps local extreme values?
What I have tried so far:
data = from(bucket: "test-bucket")
|> range(start: 0; stop: now())
|> filter(fn: (r) => r["_field"] == "sensorValue")
minData = data
|> aggregateWindow(every: 1s, fn: min, createEmpty: false)
maxData = data
|> aggregateWindow(every: 1s, fn: max, createEmpty: false)
|> yield()
This will draw 2 series. Is there any chance to merge them? Or is my approach just completly wrong?