flush-job.asciidoc 3.3 KB

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