Extract peak value above a threshhold

Hi, I am Noob to influx, using it for my ioBroker and Grafana to visualize. I am very slowly get used to basic commands, step by step.
However my today’s challenge is far beyond my knowledge so I thought…why not ask the experts ;).
Here is what I need:
I am recording traffic sound levels, delivered by a noise monitoring system. Sample rate is one second.
Now I need the level and timestamp of all peaks above a certain level (e.g. 80) and write it into the database for further use
I cannot use just “bigger than 80” as there are sometimes a couple of values before the peak is reached.
I circled what I want in the screenshot
Any help aprecciated big time :slight_smile:

1 Like


I’m not following you there - unless you also want to aggregate down to minute or hourly points.

If so, in flux you could do something like this

|> window(every: 1m)
|> max()

Where you’ve already filtered your dataset where the value is >= to your desired threshold.


thanks for your suggestion, I think I was not precise with my sample screenshot
this one might be more clear
You can see there are two values above threshold (I used 70 here) which are not the peak yet.
Third value is the peak here, but can be first, second, third, and so on, depending on the speed of the vehicle

Are you wanting to find the single (or first) max value over some period for these peaks though? From your screenshot it looks like they occur within a 6-10 second range (though I appreciate that may vary) . If that’s a yes, then flux will do exactly that using the query I posted earlier (and you can modify that to write the results into another table too). And you could window the data over 2 or 3 or 5 or 6 seconds too - probably after quantifying the typical width of these peaks .

If you don’t want to aggregate the data, then we’re back to my original question being that the two requirements (per second, and peak value) don’t seem to be compatible with each other.

Hi, I am recording 24hrs / 7 days a week.
I want to find all peak values (above a threshold) to trigger my video system which then delivers a snapshot clip corresponding to the time where a peak occurs.
Although the sampling rate is 1sec, the range between peaks can be within a couple of seconds, minutes or hours, purely depending on traffic.
Another example with a longer x-axis (time of the day)

found a simple solution with excel
I’ll start with this one for now

What you want to do is comput the delta between two consecutive values, then slide a window over two consecutive deltas and only retain the data points which have positive delta followed by a negative one, they are your peaks. Computing the max will not solve you problem.

The link as I mentioned was my starting point.
This is how it looks with a simple Excel, looks correct to me !?