delete-job.asciidoc 2.9 KB

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