delete-job.asciidoc 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * Requires the `manage_ml` cluster privilege. This privilege is included in the
  15. `machine_learning_admin` built-in role.
  16. * Before you can delete a job, you must close it (unless you specify the `force`
  17. parameter). See <<ml-close-job>>.
  18. [[ml-delete-job-desc]]
  19. == {api-description-title}
  20. All job configuration, model state and results are deleted.
  21. IMPORTANT: Deleting an {anomaly-job} must be done via this API only. Do not
  22. delete the job directly from the `.ml-*` indices using the {es} delete document
  23. API. When {es} {security-features} are enabled, make sure no `write` privileges
  24. are granted to anyone over the `.ml-*` indices.
  25. It is not currently possible to delete multiple jobs using wildcards or a comma
  26. separated list.
  27. If you delete a job that has a {dfeed}, the request first tries to delete the
  28. {dfeed}. This behavior is equivalent to calling
  29. <<ml-delete-datafeed,delete {dfeed}>> with the same `timeout` and `force`
  30. parameters as the delete job request.
  31. [[ml-delete-job-path-parms]]
  32. == {api-path-parms-title}
  33. `<job_id>`::
  34. (Required, string)
  35. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  36. [[ml-delete-job-query-parms]]
  37. == {api-query-parms-title}
  38. `force`::
  39. (Optional, Boolean) Use to forcefully delete an opened job; this method is
  40. quicker than closing and deleting the job.
  41. `wait_for_completion`::
  42. (Optional, Boolean) Specifies whether the request should return immediately or
  43. wait until the job deletion completes. Defaults to `true`.
  44. [[ml-delete-job-example]]
  45. == {api-examples-title}
  46. [source,console]
  47. --------------------------------------------------
  48. DELETE _ml/anomaly_detectors/total-requests
  49. --------------------------------------------------
  50. // TEST[skip:setup:server_metrics_job]
  51. When the job is deleted, you receive the following results:
  52. [source,console-result]
  53. ----
  54. {
  55. "acknowledged": true
  56. }
  57. ----
  58. In the next example we delete the `total-requests` job asynchronously:
  59. [source,console]
  60. --------------------------------------------------
  61. DELETE _ml/anomaly_detectors/total-requests?wait_for_completion=false
  62. --------------------------------------------------
  63. // TEST[skip:setup:server_metrics_job]
  64. When `wait_for_completion` is set to `false`, the response contains the id
  65. of the job deletion task:
  66. [source,console-result]
  67. ----
  68. {
  69. "task": "oTUltX4IQMOUUVeiohTt8A:39"
  70. }
  71. ----
  72. // TESTRESPONSE[s/"task": "oTUltX4IQMOUUVeiohTt8A:39"/"task": $body.task/]