query-watches.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. [role="xpack"]
  2. [[watcher-api-query-watches]]
  3. === Query watches API
  4. ++++
  5. <titleabbrev>Query watches</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 all registered watches.
  13. [[watcher-api-query-watches-request]]
  14. ==== {api-request-title}
  15. `GET /_watcher/_query/watches`
  16. [[watcher-api-query-watches-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 <<security-privileges>>.
  20. //[[watcher-api-query-watches-desc]]
  21. //==== {api-description-title}
  22. Retrieves all watches in a paginated manner and
  23. optionally filtering watches by a query.
  24. //[[watcher-api-query-watches-request-body]]
  25. //==== {api-request-body-title}
  26. This API supports the following fields:
  27. [cols=",^,^,", options="header"]
  28. |======
  29. | Name | Required | Default | Description
  30. | `from` | no | 0 | The offset from the first result to fetch. Needs to be non-negative.
  31. | `size` | no | 10 | The number of hits to return. Needs to be non-negative.
  32. | `query` | no | null | Optional, <<query-dsl,query>> filter watches to be returned.
  33. | `sort` | no | null | Optional <<sort-search-results,sort definition>>.
  34. | `search_after` | no | null | Optional <<search-after,search After>> to do pagination
  35. using last hit's sort values.
  36. |======
  37. Note that only the `_id` and `metadata.*` fields are queryable or sortable.
  38. //[[watcher-api-query-watches-response-body]]
  39. //==== {api-response-body-title}
  40. This api returns the following top level fields:
  41. `count`::
  42. The total number of watches found.
  43. `watches`::
  44. A list of watches based on the `from`, `size` or `search_after` request body parameters.
  45. [[watcher-api-query-watches-example]]
  46. ==== {api-examples-title}
  47. The following example list all stored watches:
  48. [source,console]
  49. --------------------------------------------------
  50. GET /_watcher/_query/watches
  51. --------------------------------------------------
  52. // TEST[setup:my_active_watch]
  53. Response:
  54. [source,console-result]
  55. --------------------------------------------------
  56. {
  57. "count": 1,
  58. "watches": [
  59. {
  60. "_id": "my_watch",
  61. "watch": {
  62. "trigger": {
  63. "schedule": {
  64. "hourly": {
  65. "minute": [
  66. 0,
  67. 5
  68. ]
  69. }
  70. }
  71. },
  72. "input": {
  73. "simple": {
  74. "payload": {
  75. "send": "yes"
  76. }
  77. }
  78. },
  79. "condition": {
  80. "always": {}
  81. },
  82. "actions": {
  83. "test_index": {
  84. "index": {
  85. "index": "test"
  86. }
  87. }
  88. }
  89. },
  90. "status": {
  91. "state": {
  92. "active": true,
  93. "timestamp": "2015-05-26T18:21:08.630Z"
  94. },
  95. "actions": {
  96. "test_index": {
  97. "ack": {
  98. "timestamp": "2015-05-26T18:21:08.630Z",
  99. "state": "awaits_successful_execution"
  100. }
  101. }
  102. },
  103. "version": -1
  104. },
  105. "_seq_no": 0,
  106. "_primary_term": 1
  107. }
  108. ]
  109. }
  110. --------------------------------------------------
  111. // TESTRESPONSE[s/"timestamp": "2015-05-26T18:21:08.630Z"/"timestamp": "$body.watches.0.status.state.timestamp"/]