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