get-watch.asciidoc 2.4 KB

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