OpenSearch/docs/reference/ml/apis/forecast.asciidoc

80 lines
2.1 KiB
Plaintext
Raw Normal View History

[role="xpack"]
[testenv="platinum"]
[[ml-forecast]]
2018-12-20 13:23:28 -05:00
=== Forecast jobs API
++++
2018-12-20 13:23:28 -05:00
<titleabbrev>Forecast jobs</titleabbrev>
++++
Predicts the future behavior of a time series by using its historical behavior.
==== Request
`POST _ml/anomaly_detectors/<job_id>/_forecast`
==== Description
See {xpack-ref}/ml-overview.html#ml-forecasting[Forecasting the Future].
[NOTE]
===============================
* If you use an `over_field_name` property in your job, you cannot create a
forecast. For more information about this property, see <<ml-job-resource>>.
* The job must be open when you create a forecast. Otherwise, an error occurs.
===============================
==== Path Parameters
`job_id`::
(string) Identifier for the job.
==== Request Parameters
`duration`::
(time units) A period of time that indicates how far into the future to
forecast. For example, `30d` corresponds to 30 days. The default value is 1
day. The forecast starts at the last record that was processed. For more
information about time units, see <<time-units>>.
`expires_in`::
(time units) The period of time that forecast results are retained.
After a forecast expires, the results are deleted. The default value is 14 days.
If set to a value of `0`, the forecast is never automatically deleted.
For more information about time units, see <<time-units>>.
==== Authorization
You must have `manage_ml`, or `manage` cluster privileges to use this API.
For more information, see {xpack-ref}/security-privileges.html[Security Privileges].
==== Examples
The following example requests a 10 day forecast for the `total-requests` job:
[source,js]
--------------------------------------------------
POST _ml/anomaly_detectors/total-requests/_forecast
{
"duration": "10d"
}
--------------------------------------------------
// CONSOLE
// TEST[skip:requires delay]
When the forecast is created, you receive the following results:
[source,js]
----
{
"acknowledged": true,
"forecast_id": "wkCWa2IB2lF8nSE_TzZo"
}
----
// NOTCONSOLE
You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.