delete-job.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[rollup-delete-job]]
  4. === Delete Job API
  5. ++++
  6. <titleabbrev>Delete Job</titleabbrev>
  7. ++++
  8. experimental[]
  9. This API deletes an existing rollup job. A job must be *stopped* first before it can be deleted. Attempting to delete
  10. a started job will result in an error. Similarly, attempting to delete a nonexistent job will throw an exception.
  11. .Deleting the job does not delete rolled up data
  12. **********************************
  13. When a job is deleted, that only removes the process that is actively monitoring and rolling up data.
  14. It does not delete any previously rolled up data. This is by design; a user may wish to roll up a static dataset. Because
  15. the dataset is static, once it has been fully rolled up there is no need to keep the indexing Rollup job around (as there
  16. will be no new data). So the job may be deleted, leaving behind the rolled up data for analysis.
  17. If you wish to also remove the rollup data, and the rollup index only contains the data for a single job, you can simply
  18. delete the whole rollup index. If the rollup index stores data from several jobs, you must issue a Delete-By-Query that
  19. targets the Rollup job's ID in the rollup index:
  20. [source,js]
  21. --------------------------------------------------
  22. POST my_rollup_index/_delete_by_query
  23. {
  24. "query": {
  25. "term": {
  26. "_rollup.id": "the_rollup_job_id"
  27. }
  28. }
  29. }
  30. --------------------------------------------------
  31. // NOTCONSOLE
  32. **********************************
  33. ==== Request
  34. `DELETE _rollup/job/<job_id>`
  35. //===== Description
  36. ==== Path Parameters
  37. `job_id` (required)::
  38. (string) Identifier for the job
  39. ==== Request Body
  40. There is no request body for the Delete Job API.
  41. ==== Authorization
  42. You must have `manage` or `manage_rollup` cluster privileges to use this API.
  43. For more information, see
  44. {xpack-ref}/security-privileges.html[Security Privileges].
  45. ==== Examples
  46. If we have a rollup job named `sensor`, it can be deleted with:
  47. [source,js]
  48. --------------------------------------------------
  49. DELETE _rollup/job/sensor
  50. --------------------------------------------------
  51. // CONSOLE
  52. // TEST[setup:sensor_rollup_job]
  53. Which will return the response:
  54. [source,js]
  55. ----
  56. {
  57. "acknowledged": true
  58. }
  59. ----
  60. // TESTRESPONSE
  61. If however we try to delete a job which doesn't exist:
  62. [source,js]
  63. --------------------------------------------------
  64. DELETE _rollup/job/does_not_exist
  65. --------------------------------------------------
  66. // CONSOLE
  67. // TEST[catch:missing]
  68. A 404 `resource_not_found` exception will be thrown:
  69. [source,js]
  70. ----
  71. {
  72. "error" : {
  73. "root_cause" : [
  74. {
  75. "type" : "resource_not_found_exception",
  76. "reason" : "the task with id [does_not_exist] doesn't exist",
  77. "stack_trace": ...
  78. }
  79. ],
  80. "type" : "resource_not_found_exception",
  81. "reason" : "the task with id [does_not_exist] doesn't exist",
  82. "stack_trace": ...
  83. },
  84. "status": 404
  85. }
  86. ----
  87. // TESTRESPONSE[s/"stack_trace": .../"stack_trace": $body.$_path/]