flush-job.asciidoc 3.1 KB

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