query-watches.asciidoc 3.8 KB

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