0

I am using the Forecast API in X-pack to produce a 30 day forecast like this

POST _xpack/ml/anomaly_detectors/my_job/_forecast
{
    "duration": "30d"
}

and get an acknowledgement response with a forecast_id. I'm trying to retrieve the forecast data so I can make some further data processing on the predicted data. So is there any way to extract/retrieve the forecast data by using the forecast_id or something like that? The data certainly exists since it shows up properly in Kibana's Machine Learning tab.

uyth
  • 3
  • 2

1 Answers1

1

Yes you absolute can retrieve the forecast data. All ML results are simply stored in an indexed document, so you just have to do a query to search for the results.

Example:

GET .ml-anomalies*/_search
{
  "query": {
    "bool" :{
      "filter": [
        { 
          "query_string":{
            "query": "result_type:model_forecast",
            "analyze_wildcard": true
          }
        },
        {"term": { "job_id": "$MY_JOB_ID"}},
        {"term": { "forecast_id": "$MY_FORECAST_ID"}}]
    }
  }
}
Benjamin Trent
  • 7,378
  • 3
  • 31
  • 41