Query help - alerting when value above threshold for 5 seconds

I have a question about a specific query and alert. I’m receiving constant positioning data to one database that I can graph in real-time with the query SELECT “coord_x” FROM “position” WHERE $timeFilter.

I’d like to trigger an alert when that value is above 10,000 for over 5 seconds.

“WHEN max() OF query(A, 5s, now) IS ABOVE 10000” registers and alerts the spikes over 10000, but that’s too many false positives. I’m thinking I need to change the query to give me one avg() value over the last 5 seconds but I can’t get it to work.

Any help? Thanks.

Surely you want to check min() instead of max()?

If you want to alert when the value stays above 10,000 for over 5 seconds, you
want to be sure that the minimum value during those 5 seconds is higher than
10,000 (and therefore every other value during the 5 seconds must have been
above 10,000 as well).

If the minimum is less than 10,000, then it didn’t stay high enough for long
enough, so no alert.

Regards,

Antony.

Thanks for the reply. As I was implementing your solution I realized I have the issue that my coordinates ping pong between positive and negative values thus reporting negative min values and not maintaining a sustained value above 10000. I decided to just plot points above zero and alert when avg() is above 8000. Seems to be working.