forecast.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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) A period of time that indicates how far into the future
  34. to forecast. For example, `30d` corresponds to 30 days. The default value is 1
  35. day. The forecast starts at the last record that was processed. For more
  36. information about time units, see <<time-units>>.
  37. `expires_in`::
  38. (Optional, 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. For more information about time units, see <<time-units>>.
  42. [[ml-forecast-example]]
  43. ==== {api-examples-title}
  44. The following example requests a 10 day forecast for the `total-requests` job:
  45. [source,js]
  46. --------------------------------------------------
  47. POST _ml/anomaly_detectors/total-requests/_forecast
  48. {
  49. "duration": "10d"
  50. }
  51. --------------------------------------------------
  52. // CONSOLE
  53. // TEST[skip:requires delay]
  54. When the forecast is created, you receive the following results:
  55. [source,js]
  56. ----
  57. {
  58. "acknowledged": true,
  59. "forecast_id": "wkCWa2IB2lF8nSE_TzZo"
  60. }
  61. ----
  62. // NOTCONSOLE
  63. You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.