get-watch.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. [role="xpack"]
  2. [[watcher-api-get-watch]]
  3. === Get watch API
  4. ++++
  5. <titleabbrev>Get watch</titleabbrev>
  6. ++++
  7. Retrieves a watch by its ID.
  8. [[watcher-api-get-watch-request]]
  9. ==== {api-request-title}
  10. `GET _watcher/watch/<watch_id>`
  11. [[watcher-api-get-watch-prereqs]]
  12. ==== {api-prereq-title}
  13. * You must have `manage_watcher` or `monitor_watcher` cluster privileges to use
  14. this API. For more information, see
  15. <<security-privileges>>.
  16. //[[watcher-api-get-watch-desc]]
  17. //==== {api-description-title}
  18. [[watcher-api-get-watch-path-params]]
  19. ==== {api-path-parms-title}
  20. `<watch_id>`::
  21. (Required, string) Identifier for the watch.
  22. //[[watcher-api-get-watch-query-params]]
  23. //==== {api-query-parms-title}
  24. //[[watcher-api-get-watch-request-body]]
  25. //==== {api-request-body-title}
  26. //[[watcher-api-get-watch-response-body]]
  27. //==== {api-response-body-title}
  28. //[[watcher-api-get-watch-response-codes]]
  29. //==== {api-response-codes-title}
  30. [[watcher-api-get-watch-example]]
  31. ==== {api-examples-title}
  32. The following example gets a watch with `my_watch` id:
  33. [source,console]
  34. --------------------------------------------------
  35. GET _watcher/watch/my_watch
  36. --------------------------------------------------
  37. // TEST[setup:my_active_watch]
  38. Response:
  39. [source,console-result]
  40. --------------------------------------------------
  41. {
  42. "found": true,
  43. "_id": "my_watch",
  44. "_seq_no": 0,
  45. "_primary_term": 1,
  46. "_version": 1,
  47. "status": { <1>
  48. "version": 1,
  49. "state": {
  50. "active": true,
  51. "timestamp": "2015-05-26T18:21:08.630Z"
  52. },
  53. "actions": {
  54. "test_index": {
  55. "ack": {
  56. "timestamp": "2015-05-26T18:21:08.630Z",
  57. "state": "awaits_successful_execution"
  58. }
  59. }
  60. }
  61. },
  62. "watch": {
  63. "input": {
  64. "simple": {
  65. "payload": {
  66. "send": "yes"
  67. }
  68. }
  69. },
  70. "condition": {
  71. "always": {}
  72. },
  73. "trigger": {
  74. "schedule": {
  75. "hourly": {
  76. "minute": [0, 5]
  77. }
  78. }
  79. },
  80. "actions": {
  81. "test_index": {
  82. "index": {
  83. "index": "test"
  84. }
  85. }
  86. }
  87. }
  88. }
  89. --------------------------------------------------
  90. // TESTRESPONSE[s/"timestamp": "2015-05-26T18:21:08.630Z"/"timestamp": "$body.status.state.timestamp"/]
  91. <1> The current status of the watch