# Is it possible to forecast automatically in Machine Learning module?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-forecast-automatically-in-machine-learning-module/182861
**Category:** Kibana
**Tags:** elastic-stack-machine-learning
**Created:** [May 27, 2019, 8:29am UTC](https://discuss.elastic.co/t/is-it-possible-to-forecast-automatically-in-machine-learning-module/182861 "2019-05-27T08:29:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hallward\_Bagus](https://avatars.discourse-cdn.com/v4/letter/h/f475e1/32.png) [@Hallward\_Bagus](https://discuss.elastic.co/u/Hallward_Bagus)
#### Post date: [May 27, 2019, 8:29am UTC](https://discuss.elastic.co/t/is-it-possible-to-forecast-automatically-in-machine-learning-module/182861/1 "2019-05-27T08:29:04Z")

</div>

Hi Team,  
Kindly let me know if I can do forecast automatically from Machine Learning module in Kibana UI? I already created a ML Job and data feed it real time. Now, I want to forecast it but not manually. For example, I need to run forecast for 1 day at 07:00 in the morning and then in the next morning at the same time, I will run it again for 1 day. This process will repeat every day and it is hard to do it manually. Is it possible to run forecast automatically using Kibana UI?

Kibana and Elastic version: 6.6.2

Regards,  
Hallward Bagus

---

<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: [May 29, 2019, 4:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-forecast-automatically-in-machine-learning-module/182861/2 "2019-05-29T16:13:01Z")

</div>

The forecasting can be automated using the `_forecast` API: [https://www.elastic.co/guide/en/elasticsearch/reference/7.1/ml-forecast.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/ml-forecast.html)

(You will have to construct your own automation script/cron job)

Notice that each invocation of the `_forecast` returns a `forecast_id` that one can reference on a subsequent query to the `.ml-anomalies-*` index.

The steps would look something like:

```auto
POST _xpack/ml/anomaly_detectors/a_forecast_example/_open 

POST _xpack/ml/anomaly_detectors/a_forecast_example/_forecast
   {
    "duration": "1d"
   }

GET .ml-anomalies-*/_search
   {
    "query": {
      "bool": {
        "filter": [
          {"term": {"forecast_id": "pfVYBGsBvI8wQ5-C3xC9"}},
          {"term": {"result_type": "model_forecast"}},
          {"term": {"job_id": "a_forecast_example"}}
        ]
} }
}

```

---

<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: [June 26, 2019, 4:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-forecast-automatically-in-machine-learning-module/182861/3 "2019-06-26T16:13:12Z")

</div>

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