close-job.asciidoc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * If the {es} {security-features} are enabled, you must have `manage_ml` or
  20. `manage` cluster privileges to use this API. See
  21. {stack-ov}/security-privileges.html[Security privileges].
  22. [[ml-close-job-desc]]
  23. ==== {api-description-title}
  24. You can close multiple {anomaly-jobs} in a single API request by using a group
  25. name, a comma-separated list of jobs, or a wildcard expression. You can close
  26. all jobs by using `_all` or by specifying `*` as the `<job_id>`.
  27. When you close a job, it runs housekeeping tasks such as pruning the model history,
  28. flushing buffers, calculating final results and persisting the model snapshots.
  29. Depending upon the size of the job, it could take several minutes to close and
  30. the equivalent time to re-open.
  31. After it is closed, the job has a minimal overhead on the cluster except for
  32. maintaining its meta data. Therefore it is a best practice to close jobs that
  33. are no longer required to process data.
  34. When a {dfeed} that has a specified end date stops, it automatically closes
  35. the job.
  36. NOTE: If you use the `force` query parameter, the request returns without performing
  37. the associated actions such as flushing buffers and persisting the model snapshots.
  38. Therefore, do not use this parameter if you want the job to be in a consistent state
  39. after the close job API returns. The `force` query parameter should only be used in
  40. situations where the job has already failed, or where you are not interested in
  41. results the job might have recently produced or might produce in the future.
  42. [[ml-close-job-path-parms]]
  43. ==== {api-path-parms-title}
  44. `<job_id>`::
  45. (Required, string) Identifier for the {anomaly-job}. It can be a job
  46. identifier, a group name, or a wildcard expression.
  47. [[ml-close-job-query-parms]]
  48. ==== {api-query-parms-title}
  49. `force`::
  50. (Optional, boolean) Use to close a failed job, or to forcefully close a job
  51. which has not responded to its initial close request.
  52. `timeout`::
  53. (Optional, time units) Controls the time to wait until a job has closed.
  54. The default value is 30 minutes.
  55. [[ml-close-job-example]]
  56. ==== {api-examples-title}
  57. The following example closes the `total-requests` job:
  58. [source,js]
  59. --------------------------------------------------
  60. POST _ml/anomaly_detectors/total-requests/_close
  61. --------------------------------------------------
  62. // CONSOLE
  63. // TEST[skip:setup:server_metrics_openjob]
  64. When the job is closed, you receive the following results:
  65. [source,js]
  66. ----
  67. {
  68. "closed": true
  69. }
  70. ----
  71. // TESTRESPONSE