# Automatic alerting on forcast (machine learning)

**URL:** <https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [January 5, 2021, 5:15pm UTC](https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248 "2021-01-05T17:15:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Landry](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Landry](https://discuss.elastic.co/u/Landry)\
**Post date:** [January 5, 2021, 5:15pm UTC](https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248/1 "2021-01-05T17:15:59Z")

</div>

Hello,

How can we automate machine learning forcast execution in order to notify customers when some unusual events will occurs in the next days.

We have a machine learning job that detect anomalies on our datas. Actualy we use watcher to notify customers about thoses anomalies.

As the job and the datafeeders are always open we dont have to schedule the anomaly detection process pour self. Elastic do the job automaticaly.

But for forcast we dont know how we can automate the execution days after days.

Any help will be appreciate.

Thanks  
Landry

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [January 5, 2021, 10:24pm UTC](https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248/2 "2021-01-05T22:24:43Z")

</div>

Hi Landry,

Just so you know - forecasting only forecasts _trends_ in the data, not anomalies (as that would be impossible).

This question has been answered here in the forum before - see:

> [@Combining Machine Learning forecasts with Watchers](https://discuss.elastic.co/t/combining-machine-learning-forecasts-with-watchers/136318):
>
> Hello, Anyone knows if we can combine forecasts data with watchers. For example, I have created a forecast job that predicts the behavior of a product after 3 weeks. So, now I want gather these data and create a threshold alert using watchers. How can I use the data and how can I create an alert? Thank you very much in advance! Angelos

> [@Alerting on forecast](https://discuss.elastic.co/t/alerting-on-forecast/254100):
>
> Hi, im trying to alert when the forecast prediction value is greater than 95, I need to get the hostname (partition\_value) and the time when the value surpass the treshold of 95, I currently can get the value and the partition\_field\_value, but I cant get the time. GET .ml-anomalies-custom-prediction\*/\_search { "size": 0, "query": { "bool": { "filter": { "range": { "timestamp": { "gte": "now", "lte": "now+4d", "format": "strict…

---

<div class="post-metadata">

**Author:** ![Landry](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Landry](https://discuss.elastic.co/u/Landry)\
**Post date:** [January 6, 2021, 10:30am UTC](https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248/3 "2021-01-06T10:30:27Z")

</div>

Hi Rich,

Your links are helpfull.

But, concerning the **automation** part, how can i put it in place ?

Il want to launch forcasting **every day or evry week for the next day or the next week** and then alert when some forcast hight.

Do elasticsearch provide a feature for that ? Or do i have to call de forcast API using an external scheduler ?

Thank you very much in advance!  
Landry

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [January 6, 2021, 12:59pm UTC](https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248/4 "2021-01-06T12:59:28Z")

</div>

The forecasting itself doesn't have a scheduler, but you can use Watcher itself do accomplish this. You would have an independent Watch (separate from the Watch used for alerting) that did the following:

1. Runs every X (day, week, etc.)
2. executes the forecast API via the [HTTP input](https://www.elastic.co/guide/en/elasticsearch/reference/current/input-http.html)
3. obtains the unique `forecast_id` from the response from the API call in 2)
4. Possibly stores this `forecast_id` in a lookup table/index using Watcher's [indexing action](https://www.elastic.co/guide/en/elasticsearch/reference/current/actions-index.html) with the timestamp of when the forecast was run for reference by the other, alerting Watch

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 3, 2021, 12:59pm UTC](https://discuss.elastic.co/t/automatic-alerting-on-forcast-machine-learning/260248/5 "2021-02-03T12:59:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
