Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›REST APIs ›Watcher APIs

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:

resp = client.watcher.get_watch(
    id="my_watch",
)
print(resp)
const response = await client.watcher.getWatch({
  id: "my_watch",
});
console.log(response);
GET _watcher/watch/my_watch
{
  "found": true,
  "_id": "my_watch",
  "_seq_no": 0,
  "_primary_term": 1,
  "_version": 1,
  "status": {
    "state" : {
      "active" : false,
      "timestamp" : "2015-08-20T12:21:32.734Z"
    },
    "actions": ...,
    "version": 1
  },
  "watch": ...
}

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

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

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

{
  "status": {
    "state" : {
      "active" : true,
      "timestamp" : "2015-09-04T08:39:46.816Z"
    },
    "actions": ...,
    "version": 1
  }
}

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/watcher-api-activate-watch.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API