close-job.asciidoc 2.9 KB

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