close-job.asciidoc 3.3 KB

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