delete-job.asciidoc 2.6 KB

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