flush-job.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. Requires the `manage_ml` cluster privilege. This privilege is included in the
  15. `machine_learning_admin` built-in role.
  16. [[ml-flush-job-desc]]
  17. == {api-description-title}
  18. The flush jobs API is only applicable when sending data for analysis using the
  19. <<ml-post-data,post data API>>. Depending on the content of the buffer, then it
  20. might additionally calculate new results.
  21. Both flush and close operations are similar, however the flush is more efficient
  22. if you are expecting to send more data for analysis. When flushing, the job
  23. remains open and is available to continue analyzing data. A close operation
  24. additionally prunes and persists the model state to disk and the job must be
  25. opened again before analyzing further data.
  26. [[ml-flush-job-path-parms]]
  27. == {api-path-parms-title}
  28. `<job_id>`::
  29. (Required, string)
  30. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  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. [source,console]
  52. --------------------------------------------------
  53. POST _ml/anomaly_detectors/low_request_rate/_flush
  54. {
  55. "calc_interim": true
  56. }
  57. --------------------------------------------------
  58. // TEST[skip:Kibana sample data]
  59. When the operation succeeds, you receive the following results:
  60. [source,console-result]
  61. ----
  62. {
  63. "flushed": true,
  64. "last_finalized_bucket_end": 1455234900000
  65. }
  66. ----
  67. //TESTRESPONSE[s/"last_finalized_bucket_end": 1455234900000/"last_finalized_bucket_end": $body.last_finalized_bucket_end/]
  68. The `last_finalized_bucket_end` provides the timestamp (in
  69. milliseconds-since-the-epoch) of the end of the last bucket that was processed.
  70. If you want to flush the job to a specific timestamp, you can use the
  71. `advance_time` or `skip_time` parameters. For example, to advance to 11 AM GMT
  72. on January 1, 2018:
  73. [source,console]
  74. --------------------------------------------------
  75. POST _ml/anomaly_detectors/total-requests/_flush
  76. {
  77. "advance_time": "1514804400000"
  78. }
  79. --------------------------------------------------
  80. // TEST[skip:setup:server_metrics_openjob]
  81. When the operation succeeds, you receive the following results:
  82. [source,console-result]
  83. ----
  84. {
  85. "flushed": true,
  86. "last_finalized_bucket_end": 1514804400000
  87. }
  88. ----