flush-job.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-flush-job]]
  4. === Flush jobs API
  5. ++++
  6. <titleabbrev>Flush jobs</titleabbrev>
  7. ++++
  8. Forces any buffered data to be processed by the job.
  9. [[ml-flush-job-request]]
  10. ==== {api-request-title}
  11. `POST _ml/anomaly_detectors/<job_id>/_flush`
  12. [[ml-flush-job-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-flush-job-desc]]
  18. ==== {api-description-title}
  19. The flush jobs API is only applicable when sending data for analysis using the
  20. <<ml-post-data,post data API>>. Depending on the content of the buffer, then it
  21. might additionally calculate new results.
  22. Both flush and close operations are similar, however the flush is more efficient
  23. if you are expecting to send more data for analysis. When flushing, the job
  24. remains open and is available to continue analyzing data. A close operation
  25. additionally prunes and persists the model state to disk and the job must be
  26. opened again before analyzing further data.
  27. [[ml-flush-job-path-parms]]
  28. ==== {api-path-parms-title}
  29. `<job_id>`::
  30. (string) Required. Identifier for the job.
  31. [[ml-flush-job-query-parms]]
  32. ==== {api-query-parms-title}
  33. `advance_time`::
  34. (string) Optional. Specifies to advance to a particular time value. Results are
  35. generated and the model is updated for data from the specified time interval.
  36. `calc_interim`::
  37. (boolean) Optional. If true, calculates the interim results for the most
  38. recent bucket or all buckets within the latency period.
  39. `end`::
  40. (string) Optional. When used in conjunction with `calc_interim`, specifies the
  41. range of buckets on which to calculate interim results.
  42. `skip_time`::
  43. (string) Optional. Specifies to skip to a particular time value. Results are
  44. not generated and the model is not updated for data from the specified time
  45. interval.
  46. `start`::
  47. (string) Optional. When used in conjunction with `calc_interim`, specifies the
  48. range of buckets on which to calculate interim results.
  49. [[ml-flush-job-example]]
  50. ==== {api-examples-title}
  51. The following example flushes the `total-requests` job:
  52. [source,js]
  53. --------------------------------------------------
  54. POST _ml/anomaly_detectors/total-requests/_flush
  55. {
  56. "calc_interim": true
  57. }
  58. --------------------------------------------------
  59. // CONSOLE
  60. // TEST[skip:setup:server_metrics_openjob]
  61. When the operation succeeds, you receive the following results:
  62. [source,js]
  63. ----
  64. {
  65. "flushed": true,
  66. "last_finalized_bucket_end": 1455234900000
  67. }
  68. ----
  69. //TESTRESPONSE[s/"last_finalized_bucket_end": 1455234900000/"last_finalized_bucket_end": $body.last_finalized_bucket_end/]
  70. The `last_finalized_bucket_end` provides the timestamp (in
  71. milliseconds-since-the-epoch) of the end of the last bucket that was processed.
  72. If you want to flush the job to a specific timestamp, you can use the
  73. `advance_time` or `skip_time` parameters. For example, to advance to 11 AM GMT
  74. on January 1, 2018:
  75. [source,js]
  76. --------------------------------------------------
  77. POST _ml/anomaly_detectors/total-requests/_flush
  78. {
  79. "advance_time": "1514804400"
  80. }
  81. --------------------------------------------------
  82. // CONSOLE
  83. // TEST[skip:setup:server_metrics_openjob]
  84. When the operation succeeds, you receive the following results:
  85. [source,console-result]
  86. ----
  87. {
  88. "flushed": true,
  89. "last_finalized_bucket_end": 1514804400000
  90. }
  91. ----