delete-job.asciidoc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-delete-job]]
  4. = Delete {anomaly-jobs} API
  5. ++++
  6. <titleabbrev>Delete jobs</titleabbrev>
  7. ++++
  8. Deletes an existing {anomaly-job}.
  9. [[ml-delete-job-request]]
  10. == {api-request-title}
  11. `DELETE _ml/anomaly_detectors/<job_id>`
  12. [[ml-delete-job-prereqs]]
  13. == {api-prereq-title}
  14. * If {es} {security-features} are enabled, you must have `manage_ml` or `manage`
  15. cluster privileges to use this API. See <<security-privileges>> and
  16. {ml-docs-setup-privileges}.
  17. * Before you can delete a job, you must delete the {dfeeds} that are associated
  18. with it. See <<ml-delete-datafeed>>.
  19. * Before you can delete a job, you must close it (unless you specify the `force` parameter). See <<ml-close-job>>.
  20. [[ml-delete-job-desc]]
  21. == {api-description-title}
  22. All job configuration, model state and results are deleted.
  23. IMPORTANT: Deleting an {anomaly-job} must be done via this API only. Do not
  24. delete the job directly from the `.ml-*` indices using the {es} delete document
  25. API. When {es} {security-features} are enabled, make sure no `write` privileges
  26. are granted to anyone over the `.ml-*` indices.
  27. It is not currently possible to delete multiple jobs using wildcards or a comma
  28. separated list.
  29. [[ml-delete-job-path-parms]]
  30. == {api-path-parms-title}
  31. `<job_id>`::
  32. (Required, string)
  33. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  34. [[ml-delete-job-query-parms]]
  35. == {api-query-parms-title}
  36. `force`::
  37. (Optional, boolean) Use to forcefully delete an opened job; this method is
  38. quicker than closing and deleting the job.
  39. `wait_for_completion`::
  40. (Optional, boolean) Specifies whether the request should return immediately or
  41. wait until the job deletion completes. Defaults to `true`.
  42. [[ml-delete-job-example]]
  43. == {api-examples-title}
  44. [source,console]
  45. --------------------------------------------------
  46. DELETE _ml/anomaly_detectors/total-requests
  47. --------------------------------------------------
  48. // TEST[skip:setup:server_metrics_job]
  49. When the job is deleted, you receive the following results:
  50. [source,console-result]
  51. ----
  52. {
  53. "acknowledged": true
  54. }
  55. ----
  56. In the next example we delete the `total-requests` job asynchronously:
  57. [source,console]
  58. --------------------------------------------------
  59. DELETE _ml/anomaly_detectors/total-requests?wait_for_completion=false
  60. --------------------------------------------------
  61. // TEST[skip:setup:server_metrics_job]
  62. When `wait_for_completion` is set to `false`, the response contains the id
  63. of the job deletion task:
  64. [source,console-result]
  65. ----
  66. {
  67. "task": "oTUltX4IQMOUUVeiohTt8A:39"
  68. }
  69. ----
  70. // TESTRESPONSE[s/"task": "oTUltX4IQMOUUVeiohTt8A:39"/"task": $body.task/]