# Export forecast data

**URL:** https://discuss.elastic.co/t/export-forecast-data/124875
**Category:** Elasticsearch
**Tags:** elastic-stack-machine-learning
**Created:** [March 20, 2018, 11:16pm UTC](https://discuss.elastic.co/t/export-forecast-data/124875 "2018-03-20T23:16:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Oscarlf](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@Oscarlf](https://discuss.elastic.co/u/Oscarlf)
#### Post date: [March 20, 2018, 11:16pm UTC](https://discuss.elastic.co/t/export-forecast-data/124875/1 "2018-03-20T23:16:42Z")

</div>

Hi everyone!

Is there any possibility of exporting the data reflected in a forecast scenario? I can see it and the comparison in the Single Metric Viewer, but I would like to use it or manage it to do some other calculations, since it was the purpose to forecast that data, in my case capacity planning, for example.

Thanks in advance!

OL

---

<div class="post-metadata">

### Author: ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)
#### Post date: [March 21, 2018, 8:12am UTC](https://discuss.elastic.co/t/export-forecast-data/124875/2 "2018-03-21T08:12:09Z")

</div>

Hi Oscar,

all forecast results are written back to the result index of the job, that is default the shared index: `.ml-anomalies-shared` but you can also use a dedicated index.

Therefore you can access all results via search, e.g.

```
GET .ml-anomalies-shared/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "query_string": {
            "query": "result_type:model_forecast"
          }
        },
        {
          "query_string": {
            "query": "job_id:n1"
          }
        }
      ]
    }
  }
}

```

In the result you will see the fields `forecast_lower`, `forecast_upper`, `forecast_prediction` along with `timestamp` which is the timestamp of the prediction.

Happy forecasting!

---

<div class="post-metadata">

### Author: ![Oscarlf](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@Oscarlf](https://discuss.elastic.co/u/Oscarlf)
#### Post date: [March 28, 2018, 4:44pm UTC](https://discuss.elastic.co/t/export-forecast-data/124875/3 "2018-03-28T16:44:28Z")

</div>

Hi Hendrik\_Muhs, so helpful your support, Thanks a lot.

But you kow, I'm wondering if there is a chance to export this data, I mean, like when we are in a "Visualize" table and there is an option to export in "raw" or "formatted". The think is that we are trying to use all the "forectast\_prediction" data to do some other analysis like capacity requirements, etc.

Besides, when we run a forecast scenario on the job and it has more than one "detector", how could I filter the one I want to see? Running the query you suggested it appears a "detector\_index" followed by a number but doesn's seems to have a relation or can't find it yet. Could you please help with this?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)
#### Post date: [April 4, 2018, 8:07pm UTC](https://discuss.elastic.co/t/export-forecast-data/124875/4 "2018-04-04T20:07:24Z")

</div>

Hi Oscar,

sorry for the late reply. As said exporting data can be done via queries and some scripting around it. Having that said, there is also the possibility to use the kibana UI to export the data using "Visualize", e.g. a table view. The 1st step to be done is making the data visible for kibana by creating an index pattern, via `management`/`kibana`/`index patterns`/`create index pattern`. Check `include system indices` and create an index pattern for `.ml-anomalies-shared` or `.ml-anomalies-JOBID` if you use a dedicated index. That should make the data visible for all kibana visualizations. As 2nd step you can now create a table visualization using the fields of interest e.g. `forecast_prediction` as metric and a data histogram for the buckets with the granularity of your choice. The data can now be exported using `Export`.

Regarding your 2nd question about selecting the detector: As `detector index` is a number a `match query` should do the trick, for example:

```auto
GET .ml-anomalies-shared/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "query_string": {
            "query": "result_type:model_forecast"
          }
        },
        {
          "query_string": {
            "query": "job_id:j1"
          }
        },
        {
          "match": {
            "detector_index": "2"
          }
        }
      ]
    }
  }
}

```

---

<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: [May 2, 2018, 8:07pm UTC](https://discuss.elastic.co/t/export-forecast-data/124875/5 "2018-05-02T20:07:26Z")

</div>

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