Delete forecasts API
Deletes forecasts from a machine learning job.
Request
DELETE _ml/anomaly_detectors/<job_id>/_forecast
DELETE _ml/anomaly_detectors/<job_id>/_forecast/<forecast_id>
DELETE _ml/anomaly_detectors/<job_id>/_forecast/_all
Prerequisites
Requires the manage_ml cluster privilege. This privilege is included in the machine_learning_admin built-in role.
Description
By default, forecasts are retained for 14 days. You can specify a different retention period with the expires_in parameter in the forecast jobs API. The delete forecast API enables you to delete one or more forecasts before they expire.
When you delete a job, its associated forecasts are deleted.
For more information, see Forecasting the future.
Path parameters
-
<forecast_id> - (Optional, string) A comma-separated list of forecast identifiers. If you do not specify this optional parameter or if you specify
_allor*the API deletes all forecasts from the job. -
<job_id> - (Required, string) Identifier for the anomaly detection job.
Query parameters
-
allow_no_forecasts - (Optional, Boolean) Specifies whether an error occurs when there are no forecasts. In particular, if this parameter is set to
falseand there are no forecasts associated with the job, attempts to delete all forecasts return an error. The default value istrue. -
timeout - (Optional, time units) Specifies the period of time to wait for the completion of the delete operation. When this period of time elapses, the API fails and returns an error. The default value is
30s.
Examples
resp = client.ml.delete_forecast(
job_id="total-requests",
forecast_id="_all",
)
print(resp) response = client.ml.delete_forecast( job_id: 'total-requests', forecast_id: '_all' ) puts response
const response = await client.ml.deleteForecast({
job_id: "total-requests",
forecast_id: "_all",
});
console.log(response); DELETE _ml/anomaly_detectors/total-requests/_forecast/_all
If the request does not encounter errors, you receive the following result:
{
"acknowledged": true
}
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ml-delete-forecast.html