close-job.asciidoc 3.5 KB

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