close-job.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. [role="xpack"]
  2. [[ml-close-job]]
  3. = Close {anomaly-jobs} API
  4. ++++
  5. <titleabbrev>Close jobs</titleabbrev>
  6. ++++
  7. Closes one or more {anomaly-jobs}.
  8. [[ml-close-job-request]]
  9. == {api-request-title}
  10. `POST _ml/anomaly_detectors/<job_id>/_close` +
  11. `POST _ml/anomaly_detectors/<job_id>,<job_id>/_close` +
  12. `POST _ml/anomaly_detectors/_all/_close` +
  13. [[ml-close-job-prereqs]]
  14. == {api-prereq-title}
  15. * Requires the `manage_ml` cluster privilege. This privilege is included in the
  16. `machine_learning_admin` built-in role.
  17. [[ml-close-job-desc]]
  18. == {api-description-title}
  19. A job can be opened and closed multiple times throughout its lifecycle.
  20. A closed job cannot receive data or perform analysis operations, but you can
  21. still explore and navigate results.
  22. If you close an {anomaly-job} whose {dfeed} is running, the request first tries
  23. to stop the {dfeed}. This behavior is equivalent to calling
  24. <<ml-stop-datafeed,stop {dfeed}>> with the same `timeout` and `force` parameters
  25. as the close job request.
  26. When you close a job, it runs housekeeping tasks such as pruning the model history,
  27. flushing buffers, calculating final results and persisting the model snapshots.
  28. Depending upon the size of the job, it could take several minutes to close and
  29. the equivalent time to re-open.
  30. After it is closed, the job has a minimal overhead on the cluster except for
  31. maintaining its meta data. Therefore it is a best practice to close jobs that
  32. are no longer required to process data.
  33. When a {dfeed} that has a specified end date stops, it automatically closes
  34. its associated job.
  35. NOTE: If you use the `force` query parameter, the request returns without performing
  36. the associated actions such as flushing buffers and persisting the model snapshots.
  37. Therefore, do not use this parameter if you want the job to be in a consistent state
  38. after the close job API returns. The `force` query parameter should only be used in
  39. situations where the job has already failed, or where you are not interested in
  40. results the job might have recently produced or might produce in the future.
  41. [[ml-close-job-path-parms]]
  42. == {api-path-parms-title}
  43. `<job_id>`::
  44. (Required, string)
  45. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-wildcard]
  46. +
  47. You can close all jobs by using `_all` or by specifying `*` as the job
  48. identifier.
  49. [[ml-close-job-query-parms]]
  50. == {api-query-parms-title}
  51. `allow_no_match`::
  52. (Optional, Boolean)
  53. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match-jobs]
  54. `force`::
  55. (Optional, Boolean) Use to close a failed job, or to forcefully close a job
  56. which has not responded to its initial close request.
  57. `timeout`::
  58. (Optional, <<time-units, time units>>) Controls the time to wait until a job
  59. has closed. The default value is 30 minutes.
  60. [[ml-close-job-request-body]]
  61. == {api-request-body-title}
  62. You can also specify the query parameters (such as `allow_no_match` and `force`)
  63. in the request body.
  64. [[ml-close-job-response-codes]]
  65. == {api-response-codes-title}
  66. `404` (Missing resources)::
  67. If `allow_no_match` is `false`, this code indicates that there are no
  68. resources that match the request or only partial matches for the request.
  69. [[ml-close-job-example]]
  70. == {api-examples-title}
  71. [source,console]
  72. --------------------------------------------------
  73. POST _ml/anomaly_detectors/low_request_rate/_close
  74. --------------------------------------------------
  75. // TEST[skip:Kibana sample data]
  76. When the job is closed, you receive the following results:
  77. [source,console-result]
  78. ----
  79. {
  80. "closed": true
  81. }
  82. ----