Grafana alert based on calculation from multiple series

Hello everyone,
I try to create an alert for ratio between 2 series (pressure and speed of a machine).
The database is captured any changes in series and speed of the machine is usually stable, so I must use previous value to calculate the ratio.

I’m able to visualize the ratio value on graph, however alert usually return to Null.

Do you have any advice for this case? Thank you.

Welcome to the Grafana forum.

Can you share a screenshot of your alert configuration?

Thank you for your reply.
Here are my configuration for the alert.

I see your alert evaluates Query A. Is Query A the one where you are calculating the ratio and successfully visualizing it on the graph (per your original screenshot)? Maybe post it here just so it is clear.

If yes, then perhaps the query interval is such that there are ‘null’ periods and when the alert is checking, it usually evaluates during such a period. I think you can fix this by playing with the times (every 5s, every 30s, etc) of the query and the alert.

I can confirm the Query A is the ratio. In deed there’re “null” periods when the data haven’t changed so the IoT system would not record any new data. So in the query, I used parameter “usePrevious: true” to fill “null” periods with previous value and it’s able to visualize on Graph. I guess that it works on Graph but the alert doesn’t not work that way.

I think I can change alert query to get the last value for longer period (can be 1h). Thank you.