forecast.asciidoc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. <<security-privileges>>.
  17. [[ml-forecast-desc]]
  18. ==== {api-description-title}
  19. See {ml-docs}/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-put-job>>.
  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)
  30. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  31. [[ml-forecast-request-body]]
  32. ==== {api-request-body-title}
  33. `duration`::
  34. (Optional, <<time-units, time units>>) A period of time that indicates how far
  35. into the future to forecast. For example, `30d` corresponds to 30 days. The
  36. default value is 1 day. The forecast starts at the last record that was
  37. processed.
  38. `expires_in`::
  39. (Optional, <<time-units, time units>>) The period of time that forecast results are retained.
  40. After a forecast expires, the results are deleted. The default value is 14 days.
  41. If set to a value of `0`, the forecast is never automatically deleted.
  42. [[ml-forecast-example]]
  43. ==== {api-examples-title}
  44. The following example requests a 10 day forecast for the `total-requests` job:
  45. [source,console]
  46. --------------------------------------------------
  47. POST _ml/anomaly_detectors/total-requests/_forecast
  48. {
  49. "duration": "10d"
  50. }
  51. --------------------------------------------------
  52. // TEST[skip:requires delay]
  53. When the forecast is created, you receive the following results:
  54. [source,js]
  55. ----
  56. {
  57. "acknowledged": true,
  58. "forecast_id": "wkCWa2IB2lF8nSE_TzZo"
  59. }
  60. ----
  61. // NOTCONSOLE
  62. You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.