2017-06-27 20:16:51 -04:00
|
|
|
[role="xpack"]
|
2017-03-29 12:07:55 -04:00
|
|
|
[[watcher-api-ack-watch]]
|
2018-12-20 13:23:28 -05:00
|
|
|
=== Ack watch API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Ack watch</titleabbrev>
|
|
|
|
++++
|
2017-03-29 12:07:55 -04:00
|
|
|
|
2018-12-20 13:23:28 -05:00
|
|
|
{stack-ov}/actions.html#actions-ack-throttle[Acknowledging a watch] enables you
|
2019-09-05 14:19:35 -04:00
|
|
|
to manually throttle execution of the watch's actions.
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
[[watcher-api-ack-watch-request]]
|
|
|
|
==== {api-request-title}
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2018-12-08 13:57:16 -05:00
|
|
|
`PUT _watcher/watch/<watch_id>/_ack` +
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2018-12-08 13:57:16 -05:00
|
|
|
`PUT _watcher/watch/<watch_id>/_ack/<action_id>`
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
[[watcher-api-ack-watch-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
|
|
|
* You must have `manage_watcher` cluster privileges to use this API. For more
|
|
|
|
information, see {stack-ov}/security-privileges.html[Security privileges].
|
|
|
|
|
|
|
|
[[watcher-api-ack-watch-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
|
|
|
An action's _acknowledgement state_ is stored in the
|
|
|
|
`status.actions.<id>.ack.state` structure.
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
IMPORTANT: If the specified watch is currently being executed, this API will
|
|
|
|
return an error. The reason for this is to prevent overwriting of the watch
|
|
|
|
status from a watch execution.
|
|
|
|
|
|
|
|
[[watcher-api-ack-watch-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
|
|
|
`<action_id>`::
|
|
|
|
(Optional, list) A comma-separated list of the action IDs to acknowledge. If you omit
|
2017-09-14 16:01:47 -04:00
|
|
|
this parameter, all of the actions of the watch are acknowledged.
|
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
`<watch_id>`::
|
|
|
|
(Required, string) Identifier for the watch.
|
|
|
|
|
|
|
|
//[[watcher-api-ack-watch-query-params]]
|
|
|
|
//==== {api-query-parms-title}
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
//[[watcher-api-ack-watch-request-body]]
|
|
|
|
//==== {api-request-body-title}
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
//[[watcher-api-ack-watch-response-body]]
|
|
|
|
//==== {api-response-body-title}
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
//[[watcher-api-ack-watch-response-codes]]
|
|
|
|
//==== {api-response-codes-title}
|
2017-09-14 16:01:47 -04:00
|
|
|
|
2019-09-05 14:19:35 -04:00
|
|
|
[[watcher-api-ack-watch-example]]
|
|
|
|
==== {api-examples-title}
|
2017-03-29 12:07:55 -04:00
|
|
|
|
|
|
|
To demonstrate let's create a new watch:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
PUT _watcher/watch/my_watch
|
2017-03-29 12:07:55 -04:00
|
|
|
{
|
|
|
|
"trigger": {
|
|
|
|
"schedule": {
|
|
|
|
"hourly": {
|
|
|
|
"minute": [ 0, 5 ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"input": {
|
|
|
|
"simple": {
|
|
|
|
"payload": {
|
|
|
|
"send": "yes"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"condition": {
|
|
|
|
"always": {}
|
|
|
|
},
|
|
|
|
"actions": {
|
|
|
|
"test_index": {
|
|
|
|
"throttle_period": "15m",
|
|
|
|
"index": {
|
2019-01-30 14:12:13 -05:00
|
|
|
"index": "test"
|
2017-03-29 12:07:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TESTSETUP
|
|
|
|
|
|
|
|
The current status of a watch and the state of its actions is returned with the
|
|
|
|
watch definition when you call the <<watcher-api-get-watch, Get Watch API>>:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
GET _watcher/watch/my_watch
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
The action state of a newly-created watch is `awaits_successful_execution`:
|
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"found": true,
|
2019-01-30 20:14:59 -05:00
|
|
|
"_seq_no": 0,
|
|
|
|
"_primary_term": 1,
|
2018-02-20 04:09:27 -05:00
|
|
|
"_version": 1,
|
2017-03-29 12:07:55 -04:00
|
|
|
"_id": "my_watch",
|
2017-05-04 04:08:34 -04:00
|
|
|
"status": {
|
2017-03-29 12:07:55 -04:00
|
|
|
"version": 1,
|
|
|
|
"actions": {
|
|
|
|
"test_index": {
|
|
|
|
"ack": {
|
|
|
|
"timestamp": "2015-05-26T18:04:27.723Z",
|
|
|
|
"state": "awaits_successful_execution"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"state": ...
|
|
|
|
},
|
|
|
|
"watch": ...
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"state": \.\.\./"state": "$body.status.state"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
// TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-26T18:04:27.723Z"/"timestamp": "$body.status.actions.test_index.ack.timestamp"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
|
|
|
|
When the watch executes and the condition matches, the value of the `ack.state`
|
|
|
|
changes to `ackable`. Let's force execution of the watch and fetch it again to
|
|
|
|
check the status:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
POST _watcher/watch/my_watch/_execute
|
2017-06-13 03:57:10 -04:00
|
|
|
{
|
|
|
|
"record_execution" : true
|
|
|
|
}
|
|
|
|
|
2018-12-08 13:57:16 -05:00
|
|
|
GET _watcher/watch/my_watch
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
2017-06-13 03:57:10 -04:00
|
|
|
// CONSOLE
|
2017-03-29 12:07:55 -04:00
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
and the action is now in `ackable` state:
|
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"found": true,
|
|
|
|
"_id": "my_watch",
|
2019-01-30 20:14:59 -05:00
|
|
|
"_seq_no": 1,
|
|
|
|
"_primary_term": 1,
|
2018-02-20 04:09:27 -05:00
|
|
|
"_version": 2,
|
2017-05-04 04:08:34 -04:00
|
|
|
"status": {
|
2017-06-13 03:57:10 -04:00
|
|
|
"version": 2,
|
2017-03-29 12:07:55 -04:00
|
|
|
"actions": {
|
|
|
|
"test_index": {
|
|
|
|
"ack": {
|
|
|
|
"timestamp": "2015-05-26T18:04:27.723Z",
|
|
|
|
"state": "ackable"
|
2017-06-13 03:57:10 -04:00
|
|
|
},
|
|
|
|
"last_execution" : {
|
|
|
|
"timestamp": "2015-05-25T18:04:27.723Z",
|
|
|
|
"successful": true
|
|
|
|
},
|
|
|
|
"last_successful_execution" : {
|
|
|
|
"timestamp": "2015-05-25T18:04:27.723Z",
|
|
|
|
"successful": true
|
2017-03-29 12:07:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-06-13 03:57:10 -04:00
|
|
|
"state": ...,
|
2017-10-10 03:07:33 -04:00
|
|
|
"execution_state": "executed",
|
2017-06-13 03:57:10 -04:00
|
|
|
"last_checked": ...,
|
|
|
|
"last_met_condition": ...
|
2017-03-29 12:07:55 -04:00
|
|
|
},
|
|
|
|
"watch": ...
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"state": \.\.\./"state": "$body.status.state"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
// TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
|
2017-06-13 03:57:10 -04:00
|
|
|
// TESTRESPONSE[s/"last_checked": \.\.\./"last_checked": "$body.status.last_checked"/]
|
|
|
|
// TESTRESPONSE[s/"last_met_condition": \.\.\./"last_met_condition": "$body.status.last_met_condition"/]
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-26T18:04:27.723Z"/"timestamp": "$body.status.actions.test_index.ack.timestamp"/]
|
2017-06-13 03:57:10 -04:00
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-25T18:04:27.723Z"/"timestamp": "$body.status.actions.test_index.last_execution.timestamp"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
|
|
|
|
Now we can acknowledge it:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
PUT _watcher/watch/my_watch/_ack/test_index
|
|
|
|
GET _watcher/watch/my_watch
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
2017-06-13 03:57:10 -04:00
|
|
|
// TEST[continued]
|
2017-03-29 12:07:55 -04:00
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"found": true,
|
|
|
|
"_id": "my_watch",
|
2019-01-30 20:14:59 -05:00
|
|
|
"_seq_no": 2,
|
|
|
|
"_primary_term": 1,
|
2018-02-20 04:09:27 -05:00
|
|
|
"_version": 3,
|
2017-05-04 04:08:34 -04:00
|
|
|
"status": {
|
2017-06-13 03:57:10 -04:00
|
|
|
"version": 3,
|
2017-03-29 12:07:55 -04:00
|
|
|
"actions": {
|
|
|
|
"test_index": {
|
|
|
|
"ack": {
|
|
|
|
"timestamp": "2015-05-26T18:04:27.723Z",
|
2017-06-13 03:57:10 -04:00
|
|
|
"state": "acked"
|
|
|
|
},
|
|
|
|
"last_execution" : {
|
|
|
|
"timestamp": "2015-05-25T18:04:27.723Z",
|
|
|
|
"successful": true
|
|
|
|
},
|
|
|
|
"last_successful_execution" : {
|
|
|
|
"timestamp": "2015-05-25T18:04:27.723Z",
|
|
|
|
"successful": true
|
2017-03-29 12:07:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-06-13 03:57:10 -04:00
|
|
|
"state": ...,
|
2017-10-10 03:07:33 -04:00
|
|
|
"execution_state": "executed",
|
2017-06-13 03:57:10 -04:00
|
|
|
"last_checked": ...,
|
|
|
|
"last_met_condition": ...
|
2017-03-29 12:07:55 -04:00
|
|
|
},
|
|
|
|
"watch": ...
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"state": \.\.\./"state": "$body.status.state"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
// TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
|
2017-06-13 03:57:10 -04:00
|
|
|
// TESTRESPONSE[s/"last_checked": \.\.\./"last_checked": "$body.status.last_checked"/]
|
|
|
|
// TESTRESPONSE[s/"last_met_condition": \.\.\./"last_met_condition": "$body.status.last_met_condition"/]
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-26T18:04:27.723Z"/"timestamp": "$body.status.actions.test_index.ack.timestamp"/]
|
2017-06-13 03:57:10 -04:00
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-25T18:04:27.723Z"/"timestamp": "$body.status.actions.test_index.last_execution.timestamp"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
|
|
|
|
Acknowledging an action throttles further executions of that action until its
|
|
|
|
`ack.state` is reset to `awaits_successful_execution`. This happens when the
|
|
|
|
condition of the watch is not met (the condition evaluates to `false`).
|
|
|
|
|
|
|
|
You can acknowledge multiple actions by assigning the `actions` parameter a
|
|
|
|
comma-separated list of action ids:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
POST _watcher/watch/my_watch/_ack/action1,action2
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
To acknowledge all of the actions of a watch, simply omit the `actions`
|
|
|
|
parameter:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
POST _watcher/watch/my_watch/_ack
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
2018-12-08 13:57:16 -05:00
|
|
|
// TEST[s/^/POST _watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/]
|
2017-03-29 12:07:55 -04:00
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
|
2017-06-13 03:57:10 -04:00
|
|
|
The response looks like a get watch response, but only contains the status:
|
2017-03-29 12:07:55 -04:00
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2017-06-13 03:57:10 -04:00
|
|
|
"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
|
|
|
|
}
|
2017-03-29 12:07:55 -04:00
|
|
|
}
|
2017-06-13 03:57:10 -04:00
|
|
|
},
|
2017-10-10 03:07:33 -04:00
|
|
|
"execution_state": "executed",
|
2017-06-13 03:57:10 -04:00
|
|
|
"version": 2
|
|
|
|
}
|
2017-03-29 12:07:55 -04:00
|
|
|
}
|
2017-06-13 03:57:10 -04:00
|
|
|
|
2017-03-29 12:07:55 -04:00
|
|
|
--------------------------------------------------
|
2017-06-13 03:57:10 -04:00
|
|
|
// TESTRESPONSE[s/"last_checked": "2015-05-26T18:04:27.753Z"/"last_checked": "$body.status.last_checked"/]
|
|
|
|
// TESTRESPONSE[s/"last_met_condition": "2015-05-26T18:04:27.763Z"/"last_met_condition": "$body.status.last_met_condition"/]
|
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-26T18:04:27.723Z"/"timestamp": "$body.status.state.timestamp"/]
|
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-26T18:04:27.713Z"/"timestamp": "$body.status.actions.test_index.ack.timestamp"/]
|
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-25T18:04:27.733Z"/"timestamp": "$body.status.actions.test_index.last_execution.timestamp"/]
|
|
|
|
// TESTRESPONSE[s/"timestamp": "2015-05-25T18:04:27.773Z"/"timestamp": "$body.status.actions.test_index.last_successful_execution.timestamp"/]
|