delete-job.asciidoc 2.4 KB

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