How to obtain the list of <forecast_id> associated to a <job_name>

Hi,
I would like to get the list of all the <forecast_id> associated to a specific <job_name>.

I tried:

  1. GET _ml/anomaly_detectors/<job_name> but I don't obtain any information about associated forecast
  2. GET _ml/anomaly_detectors/<job_name>/_stats but I obtain only the number and status of associated forecast (no <forecast_id> list)

Any ideas?

@StephaneB,

There is currently no API to provide this information. May I ask the reason for accessing it? I am wondering if we can provide a cleaner API to achieve what you are wanting.

If you 100% need to see the forecast IDs, the way to do so would be:

GET .ml-anomalies-*/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "result_type": "model_forecast_request_stats"
          }
        },
        {
          "term": {
            "job_id": <YOUR JOB ID>
          }
        }
      ]
    }
  }
}

Hi @BenTrent ,

Thanks for your answer.

I'm working on alerting on forecast applied to some metrics (memory, cpu,..) and in order to have always the same forecast duration we have to create via API a new forecast every day. So we also need to remove the old forecast and for that, the only way is to get the <forecast_id> at the new forecast creation and to store it in a file in order to delete it the day after. That's why it could be helpful to directly request via API the list of <forecast_id> associated to a job and then to delete the <forecast_id> created the previous day.

I also observed that if you create several forecast by using Kibana GUI, there is no way to delete a specific forecast (because this option is not available on GUI and the <forecast_id> associated to each forecast is not displayed). You can only delete ALL the forecast by using the DELETE forecast API.

So, thanks a lot for the workaround you provided in your answer. It works fine!

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