flush-job.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. [[ml-flush-job-request]]
  9. == {api-request-title}
  10. `POST _ml/anomaly_detectors/<job_id>/_flush`
  11. [[ml-flush-job-prereqs]]
  12. == {api-prereq-title}
  13. Requires the `manage_ml` cluster privilege. This privilege is included in the
  14. `machine_learning_admin` built-in role.
  15. [[ml-flush-job-desc]]
  16. == {api-description-title}
  17. The flush jobs API is only applicable when sending data for analysis using the
  18. <<ml-post-data,post data API>>. Depending on the content of the buffer, then it
  19. might additionally calculate new results.
  20. Both flush and close operations are similar, however the flush is more efficient
  21. if you are expecting to send more data for analysis. When flushing, the job
  22. remains open and is available to continue analyzing data. A close operation
  23. additionally prunes and persists the model state to disk and the job must be
  24. opened again before analyzing further data.
  25. [[ml-flush-job-path-parms]]
  26. == {api-path-parms-title}
  27. `<job_id>`::
  28. (Required, string)
  29. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  30. [[ml-flush-job-query-parms]]
  31. == {api-query-parms-title}
  32. `advance_time`::
  33. (string) Optional. Specifies to advance to a particular time value. Results are
  34. generated and the model is updated for data from the specified time interval.
  35. `calc_interim`::
  36. (Boolean) Optional. If true, calculates the interim results for the most
  37. recent bucket or all buckets within the latency period.
  38. `end`::
  39. (string) Optional. When used in conjunction with `calc_interim` and `start`,
  40. specifies the range of buckets on which to calculate interim results.
  41. `skip_time`::
  42. (string) Optional. Specifies to skip to a particular time value. Results are
  43. not generated and the model is not updated for data from the specified time
  44. interval.
  45. `start`::
  46. (string) Optional. When used in conjunction with `calc_interim`, specifies the
  47. range of buckets on which to calculate interim results.
  48. [[ml-flush-job-request-body]]
  49. == {api-request-body-title}
  50. You can also specify the query parameters (such as `advance_time` and
  51. `calc_interim`) in the request body.
  52. [[ml-flush-job-example]]
  53. == {api-examples-title}
  54. [source,console]
  55. --------------------------------------------------
  56. POST _ml/anomaly_detectors/low_request_rate/_flush
  57. {
  58. "calc_interim": true
  59. }
  60. --------------------------------------------------
  61. // TEST[skip:Kibana sample data]
  62. When the operation succeeds, you receive the following results:
  63. [source,console-result]
  64. ----
  65. {
  66. "flushed": true,
  67. "last_finalized_bucket_end": 1455234900000
  68. }
  69. ----
  70. //TESTRESPONSE[s/"last_finalized_bucket_end": 1455234900000/"last_finalized_bucket_end": $body.last_finalized_bucket_end/]
  71. The `last_finalized_bucket_end` provides the timestamp (in
  72. milliseconds-since-the-epoch) of the end of the last bucket that was processed.
  73. If you want to flush the job to a specific timestamp, you can use the
  74. `advance_time` or `skip_time` parameters. For example, to advance to 11 AM GMT
  75. on January 1, 2018:
  76. [source,console]
  77. --------------------------------------------------
  78. POST _ml/anomaly_detectors/total-requests/_flush
  79. {
  80. "advance_time": "1514804400000"
  81. }
  82. --------------------------------------------------
  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. ----