Activate watch API

Activate watch API

New API reference

For the most up-to-date API details, refer to Watcher APIs.

A watch can be either active or inactive. This API enables you to activate a currently inactive watch.

Request

PUT _watcher/watch/<watch_id>/_activate

Prerequisites

  • You must have manage_watcher cluster privileges to use this API. For more information, see Security privileges.

Path parameters

<watch_id>

(Required, string) Identifier for the watch.

Examples

The status of an inactive watch is returned with the watch definition when you call the get watch API:

  1. resp = client.watcher.get_watch(
  2. id="my_watch",
  3. )
  4. print(resp)
  1. const response = await client.watcher.getWatch({
  2. id: "my_watch",
  3. });
  4. console.log(response);
  1. GET _watcher/watch/my_watch
  1. {
  2. "found": true,
  3. "_id": "my_watch",
  4. "_seq_no": 0,
  5. "_primary_term": 1,
  6. "_version": 1,
  7. "status": {
  8. "state" : {
  9. "active" : false,
  10. "timestamp" : "2015-08-20T12:21:32.734Z"
  11. },
  12. "actions": ...,
  13. "version": 1
  14. },
  15. "watch": ...
  16. }

You can activate the watch by executing the following API call:

  1. resp = client.watcher.activate_watch(
  2. watch_id="my_watch",
  3. )
  4. print(resp)
  1. const response = await client.watcher.activateWatch({
  2. watch_id: "my_watch",
  3. });
  4. console.log(response);
  1. PUT _watcher/watch/my_watch/_activate

The new state of the watch is returned as part of its overall status:

  1. {
  2. "status": {
  3. "state" : {
  4. "active" : true,
  5. "timestamp" : "2015-09-04T08:39:46.816Z"
  6. },
  7. "actions": ...,
  8. "version": 1
  9. }
  10. }