get-watch.asciidoc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. [role="xpack"]
  2. [[watcher-api-get-watch]]
  3. === Get Watch API
  4. This API retrieves a watch by its ID.
  5. [float]
  6. ==== Request
  7. `GET _xpack/watcher/watch/<watch_id>`
  8. [float]
  9. ==== Path Parameters
  10. `watch_id` (required)::
  11. (string) Identifier for the watch.
  12. [float]
  13. ==== Authorization
  14. You must have `manage_watcher` or `monitor_watcher` cluster privileges to use
  15. this API. For more information, see
  16. {xpack-ref}/security-privileges.html[Security Privileges].
  17. [float]
  18. ==== Examples
  19. The following example gets a watch with `my-watch` id:
  20. [source,js]
  21. --------------------------------------------------
  22. GET _xpack/watcher/watch/my_watch
  23. --------------------------------------------------
  24. // CONSOLE
  25. // TEST[setup:my_active_watch]
  26. Response:
  27. [source,js]
  28. --------------------------------------------------
  29. {
  30. "found": true,
  31. "_id": "my_watch",
  32. "_version": 1,
  33. "status": { <1>
  34. "version": 1,
  35. "state": {
  36. "active": true,
  37. "timestamp": "2015-05-26T18:21:08.630Z"
  38. },
  39. "actions": {
  40. "test_index": {
  41. "ack": {
  42. "timestamp": "2015-05-26T18:21:08.630Z",
  43. "state": "awaits_successful_execution"
  44. }
  45. }
  46. }
  47. },
  48. "watch": {
  49. "input": {
  50. "simple": {
  51. "payload": {
  52. "send": "yes"
  53. }
  54. }
  55. },
  56. "condition": {
  57. "always": {}
  58. },
  59. "trigger": {
  60. "schedule": {
  61. "hourly": {
  62. "minute": [0, 5]
  63. }
  64. }
  65. },
  66. "actions": {
  67. "test_index": {
  68. "index": {
  69. "index": "test",
  70. "doc_type": "test2"
  71. }
  72. }
  73. }
  74. }
  75. }
  76. --------------------------------------------------
  77. // TESTRESPONSE[s/"timestamp": "2015-05-26T18:21:08.630Z"/"timestamp": "$body.status.state.timestamp"/]
  78. <1> The current status of the watch