close-job.asciidoc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-close-job]]
  4. === Close Jobs API
  5. ++++
  6. <titleabbrev>Close Jobs</titleabbrev>
  7. ++++
  8. Closes one or more 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. ==== Request
  13. `POST _xpack/ml/anomaly_detectors/<job_id>/_close` +
  14. `POST _xpack/ml/anomaly_detectors/<job_id>,<job_id>/_close` +
  15. `POST _xpack/ml/anomaly_detectors/_all/_close` +
  16. ==== Description
  17. You can close multiple jobs in a single API request by using a group name, a
  18. comma-separated list of jobs, or a wildcard expression. You can close all jobs
  19. by using `_all` or by specifying `*` as the `<job_id>`.
  20. When you close a job, it runs housekeeping tasks such as pruning the model history,
  21. flushing buffers, calculating final results and persisting the model snapshots.
  22. Depending upon the size of the job, it could take several minutes to close and
  23. the equivalent time to re-open.
  24. After it is closed, the job has a minimal overhead on the cluster except for
  25. maintaining its meta data. Therefore it is a best practice to close jobs that
  26. are no longer required to process data.
  27. When a {dfeed} that has a specified end date stops, it automatically closes
  28. the job.
  29. NOTE: If you use the `force` query parameter, the request returns without performing
  30. the associated actions such as flushing buffers and persisting the model snapshots.
  31. Therefore, do not use this parameter if you want the job to be in a consistent state
  32. after the close job API returns. The `force` query parameter should only be used in
  33. situations where the job has already failed, or where you are not interested in
  34. results the job might have recently produced or might produce in the future.
  35. ==== Path Parameters
  36. `job_id`::
  37. (string) Identifier for the job. It can be a job identifier, a group name, or
  38. a wildcard expression.
  39. ==== Query Parameters
  40. `force`::
  41. (boolean) Use to close a failed job, or to forcefully close a job which has not
  42. responded to its initial close request.
  43. `timeout`::
  44. (time units) Controls the time to wait until a job has closed.
  45. The default value is 30 minutes.
  46. ==== Authorization
  47. You must have `manage_ml`, or `manage` cluster privileges to use this API.
  48. For more information, see {xpack-ref}/security-privileges.html[Security Privileges].
  49. ==== Examples
  50. The following example closes the `total-requests` job:
  51. [source,js]
  52. --------------------------------------------------
  53. POST _xpack/ml/anomaly_detectors/total-requests/_close
  54. --------------------------------------------------
  55. // CONSOLE
  56. // TEST[skip:setup:server_metrics_openjob]
  57. When the job is closed, you receive the following results:
  58. [source,js]
  59. ----
  60. {
  61. "closed": true
  62. }
  63. ----
  64. // TESTRESPONSE