-
Notifications
You must be signed in to change notification settings - Fork 115
Add Watcher API examples #3489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Watcher API examples #3489
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0b27186
Add Watcher API examples
lcawl 10fcdab
Update specification/watcher/activate_watch/WatcherActivateWatchReque…
lcawl 66c9575
Update specification/watcher/ack_watch/examples/response/WatcherAckWa…
lcawl 932be56
Update specification/watcher/delete_watch/examples/response/DeleteWat…
lcawl 10246cf
Update specification/watcher/stats/examples/response/WatcherStatsResp…
lcawl bea0cc6
Update specification/watcher/execute_watch/examples/response/WatcherE…
lcawl 10842f5
Update specification/watcher/get_watch/examples/response/GetWatchResp…
lcawl 51716b2
Update specification/watcher/stats/examples/response/WatcherStatsResp…
lcawl 0f050ca
Update specification/watcher/stats/examples/response/WatcherStatsResp…
lcawl c010fe3
Merge branch 'main' into watcher-examples
lcawl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
specification/watcher/ack_watch/examples/response/WatcherAckWatchResponseExample1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # summary: | ||
| description: A successful response from `POST _watcher/watch/my_watch/_ack`. | ||
| # type: response | ||
| # response_code: | ||
| value: |- | ||
| { | ||
| "status": { | ||
| "state": { | ||
| "active": true, | ||
| "timestamp": "2015-05-26T18:04:27.723Z" | ||
| }, | ||
| "last_checked": "2015-05-26T18:04:27.753Z", | ||
| "last_met_condition": "2015-05-26T18:04:27.763Z", | ||
| "actions": { | ||
| "test_index": { | ||
| "ack" : { | ||
| "timestamp": "2015-05-26T18:04:27.713Z", | ||
| "state": "acked" | ||
| }, | ||
| "last_execution" : { | ||
| "timestamp": "2015-05-25T18:04:27.733Z", | ||
| "successful": true | ||
| }, | ||
| "last_successful_execution" : { | ||
| "timestamp": "2015-05-25T18:04:27.773Z", | ||
| "successful": true | ||
| } | ||
| } | ||
| }, | ||
| "execution_state": "executed", | ||
| "version": 2 | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
specification/watcher/delete_watch/examples/response/DeleteWatchResponseExample1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # summary: | ||
| description: A successful response from `DELETE _watcher/watch/my_watch`. | ||
| # type: response | ||
| # response_code: | ||
lcawl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| value: |- | ||
| { | ||
| "found": true, | ||
| "_id": "my_watch", | ||
| "_version": 2 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| summary: Run a watch | ||
| # method_request: POST _watcher/watch/my_watch/_execute | ||
| description: > | ||
| Run `POST _watcher/watch/my_watch/_execute` to run a watch. | ||
| The input defined in the watch is ignored and the `alternative_input` is used as the payload. | ||
| The condition as defined by the watch is ignored and is assumed to evaluate to true. | ||
| The `force_simulate` action forces the simulation of `my-action`. | ||
| Forcing the simulation means that throttling is ignored and the watch is simulated by Watcher instead of being run normally. | ||
| # type: request | ||
| value: |- | ||
| { | ||
| "trigger_data" : { | ||
| "triggered_time" : "now", | ||
| "scheduled_time" : "now" | ||
| }, | ||
| "alternative_input" : { | ||
| "foo" : "bar" | ||
| }, | ||
| "ignore_condition" : true, | ||
| "action_modes" : { | ||
| "my-action" : "force_simulate" | ||
| }, | ||
| "record_execution" : true | ||
| } |
12 changes: 12 additions & 0 deletions
12
specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| summary: Run a watch with multiple action modes | ||
| # method_request: POST _watcher/watch/my_watch/_execute | ||
| description: > | ||
| Run `POST _watcher/watch/my_watch/_execute` and set a different mode for each action. | ||
| # type: request | ||
| value: |- | ||
| { | ||
| "action_modes" : { | ||
| "action1" : "force_simulate", | ||
| "action2" : "skip" | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| summary: Run a watch inline | ||
| # method_request: POST _watcher/watch/_execute | ||
| description: > | ||
| Run `POST _watcher/watch/_execute` to run a watch inline. | ||
| All other settings for this API still apply when inlining a watch. | ||
| In this example, while the inline watch defines a compare condition, during the execution this condition will be ignored. | ||
| # type: request | ||
| value: |- | ||
| { | ||
| "watch" : { | ||
| "trigger" : { "schedule" : { "interval" : "10s" } }, | ||
| "input" : { | ||
| "search" : { | ||
| "request" : { | ||
| "indices" : [ "logs" ], | ||
| "body" : { | ||
| "query" : { | ||
| "match" : { "message": "error" } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "condition" : { | ||
| "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }} | ||
| }, | ||
| "actions" : { | ||
| "log_error" : { | ||
| "logging" : { | ||
| "text" : "Found {{ctx.payload.hits.total}} errors in the logs" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
94 changes: 94 additions & 0 deletions
94
...fication/watcher/execute_watch/examples/response/WatcherExecuteWatchResponseExample1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # summary: | ||
| description: > | ||
| A successful response from `POST _watcher/watch/my_watch/_execute`. | ||
| # type: response | ||
| # response_code: | ||
lcawl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| value: |- | ||
| { | ||
| "_id": "my_watch_0-2015-06-02T23:17:55.124Z", | ||
| "watch_record": { | ||
| "@timestamp": "2015-06-02T23:17:55.124Z", | ||
| "watch_id": "my_watch", | ||
| "node": "my_node", | ||
| "messages": [], | ||
| "trigger_event": { | ||
| "type": "manual", | ||
| "triggered_time": "2015-06-02T23:17:55.124Z", | ||
| "manual": { | ||
| "schedule": { | ||
| "scheduled_time": "2015-06-02T23:17:55.124Z" | ||
| } | ||
| } | ||
| }, | ||
| "state": "executed", | ||
| "status": { | ||
| "version": 1, | ||
| "execution_state": "executed", | ||
| "state": { | ||
| "active": true, | ||
| "timestamp": "2015-06-02T23:17:55.111Z" | ||
| }, | ||
| "last_checked": "2015-06-02T23:17:55.124Z", | ||
| "last_met_condition": "2015-06-02T23:17:55.124Z", | ||
| "actions": { | ||
| "test_index": { | ||
| "ack": { | ||
| "timestamp": "2015-06-02T23:17:55.124Z", | ||
| "state": "ackable" | ||
| }, | ||
| "last_execution": { | ||
| "timestamp": "2015-06-02T23:17:55.124Z", | ||
| "successful": true | ||
| }, | ||
| "last_successful_execution": { | ||
| "timestamp": "2015-06-02T23:17:55.124Z", | ||
| "successful": true | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "input": { | ||
| "simple": { | ||
| "payload": { | ||
| "send": "yes" | ||
| } | ||
| } | ||
| }, | ||
| "condition": { | ||
| "always": {} | ||
| }, | ||
| "result": { | ||
| "execution_time": "2015-06-02T23:17:55.124Z", | ||
| "execution_duration": 12608, | ||
| "input": { | ||
| "type": "simple", | ||
| "payload": { | ||
| "foo": "bar" | ||
| }, | ||
| "status": "success" | ||
| }, | ||
| "condition": { | ||
| "type": "always", | ||
| "met": true, | ||
| "status": "success" | ||
| }, | ||
| "actions": [ | ||
| { | ||
| "id": "test_index", | ||
| "index": { | ||
| "response": { | ||
| "index": "test", | ||
| "version": 1, | ||
| "created": true, | ||
| "result": "created", | ||
| "id": "AVSHKzPa9zx62AzUzFXY" | ||
| } | ||
| }, | ||
| "status": "success", | ||
| "type": "index" | ||
| } | ||
| ] | ||
| }, | ||
| "user": "test_admin" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.