forecast.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-forecast]]
  4. === Forecast jobs API
  5. ++++
  6. <titleabbrev>Forecast jobs</titleabbrev>
  7. ++++
  8. Predicts the future behavior of a time series by using its historical behavior.
  9. [[ml-forecast-request]]
  10. ==== {api-request-title}
  11. `POST _ml/anomaly_detectors/<job_id>/_forecast`
  12. [[ml-forecast-prereqs]]
  13. ==== {api-prereq-title}
  14. * If the {es} {security-features} are enabled, you must have `manage_ml` or
  15. `manage` cluster privileges to use this API. See
  16. {stack-ov}/security-privileges.html[Security privileges].
  17. [[ml-forecast-desc]]
  18. ==== {api-description-title}
  19. See {stack-ov}/ml-overview.html#ml-forecasting[Forecasting the future].
  20. [NOTE]
  21. ===============================
  22. * If you use an `over_field_name` property in your job, you cannot create a
  23. forecast. For more information about this property, see <<ml-job-resource>>.
  24. * The job must be open when you create a forecast. Otherwise, an error occurs.
  25. ===============================
  26. [[ml-forecast-path-parms]]
  27. ==== {api-path-parms-title}
  28. `<job_id>`::
  29. (Required, string) Identifier for the job.
  30. [[ml-forecast-request-body]]
  31. ==== {api-request-body-title}
  32. `duration`::
  33. (Optional, <<time-units, time units>>) A period of time that indicates how far
  34. into the future to forecast. For example, `30d` corresponds to 30 days. The
  35. default value is 1 day. The forecast starts at the last record that was
  36. processed.
  37. `expires_in`::
  38. (Optional, <<time-units, time units>>) The period of time that forecast results are retained.
  39. After a forecast expires, the results are deleted. The default value is 14 days.
  40. If set to a value of `0`, the forecast is never automatically deleted.
  41. [[ml-forecast-example]]
  42. ==== {api-examples-title}
  43. The following example requests a 10 day forecast for the `total-requests` job:
  44. [source,console]
  45. --------------------------------------------------
  46. POST _ml/anomaly_detectors/total-requests/_forecast
  47. {
  48. "duration": "10d"
  49. }
  50. --------------------------------------------------
  51. // TEST[skip:requires delay]
  52. When the forecast is created, you receive the following results:
  53. [source,js]
  54. ----
  55. {
  56. "acknowledged": true,
  57. "forecast_id": "wkCWa2IB2lF8nSE_TzZo"
  58. }
  59. ----
  60. // NOTCONSOLE
  61. You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.