Setting up alerts for future values(next x hours)

Hi!
Really awesome to be working in Grafana. Thank you to all contributors :slight_smile:

Im having following issue:

In an influxdb I have created forecasted values that have a timestamp in the future.
I am using the “override relative time”-option in a graph with the value +6h to show these values for 6 hours ahead, relative to now. All good, works well.
However, I would like to set up alerts on these forecasted values. Now the alert syntax does not allow for (A, -6h, now), (A, +6h, now) or the like to check values in the future (when saving, Grafana throws error: “time: invalid duration”). If I just used (A, 6h, now), the alert will check the 6 hours before now, which is not really what I want.
Is there any way to accomplish setting up an alert for future values?

any ideas highly appreciated! :blush:

Hi,
yesterday I stumbled upon this article: https://developer.bring.com/blog/forecasted-alerts-with-grafana-and-influxdb/
I think it describes exactly what you try to accomplish.
The way it works is by simply deriving values over time and thus getting the incline of your data. Adding the current value to it will give you a forecast.

Just look at the statement which starts like this:

SELECT mean("used_percent") as actual,
       derivative(mean("used_percent"), 3h)  + mean("used_percent") as forecast...

It will generate two graphs… One with the current data and one where the derived growth is added to the current value which will be your forecast.

Then you can simply use (A, 6h, now) for alerting.

Good luck.

I have the exact same issue as @curlybob. I have a timeseries with forecast values that I would like to use to generate alerts.

Many thanks for the suggested webpage. I wish it would solve my problem but I fear it doesn’t. By using the derivative method one has to make the assumption that the rate of change remains constant.

For example, suppose I have a timeseries with a temperature forecast for the next 24 hours and I want to have an alert if the temperature is predicted to exceed a certain value. If I am computing the derivative during the time when the temperature is dropping (say at night) then derivative based forecast will assume that the temperature will keep dropping into the future even though we can expect the temperature is likely to rise again when the sun comes up.

It would be so much simper if the alert syntax would allow something like (A, now, now+24h). Where “A” is my forecast temperature.

3 Likes

Just to add to @chrish excellent example. We are looking to alert on predicted financial instrument prices. Relative dates should be able to work either direction, “now” is arguably the most common needed, but its needed in both directions (past and future).

1 Like