delete-job.asciidoc 2.6 KB

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