Create or update a watch
- POST also PUT /_watcher/watch/{id}
When a watch is registered, a new document that represents the watch is added to the .watches index and its trigger is immediately registered with the relevant trigger engine.
Typically for the schedule trigger, the scheduler is the trigger engine.
You must use Kibana or this API to create a watch.
Do not add a watch directly to the .watches index by using the Elasticsearch index API.
If Elasticsearch security features are enabled, do not give users write privileges on the .watches index.
When you add a watch you can also define its initial active state by setting the active parameter.
When Elasticsearch security features are enabled, your watch can index or search only on indices for which the user that stored the watch has privileges.
If the user is able to read index a, but not index b, the same will apply when the watch runs.
Required authorization
- Cluster privileges manage_watcher
Query parameters
Request body
-
actionsmap string to object -
The list of actions that will be run if the condition matches.
-
<string>object -
transformobject -
searchobject -
requestobjectrequired -
bodyobject -
queryQueryrequired -
indices_optionsobject -
allow_no_indicesboolean -
If false, the request returns an error if any wildcard expression, index alias, or
_allvalue targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targetingfoo*,bar*returns an error if an index starts withfoobut no index starts withbar. -
expand_wildcardsstring -
Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as
open,hidden.Supported values include:
all: Match any data stream or index, including hidden ones.open: Match open, non-hidden indices. Also matches any non-hidden data stream.closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden: Match hidden data streams and hidden indices. Must be combined withopen,closed, orboth.none: Wildcard expressions are not accepted.
-
Values:
allopenclosedhiddennone -
If true, missing or closed indices are not included in the response.
-
search_type -
Supported values include:
query_then_fetch: Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate.dfs_query_then_fetch: Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate.
-
Values:
query_then_fetchdfs_query_then_fetch -
throttle_periodstring -
The minimum time between actions being run. The default is 5 seconds. This default can be changed in the config file with the setting
xpack.watcher.throttle.period.default_period. If both this value and thethrottle_period_in_millisparameter are specified, Watcher uses the last parameter included in the request. -
throttle_period_in_millisnumber -
Minimum time in milliseconds between actions being run. Defaults to 5000. If both this value and the throttle_period parameter are specified, Watcher uses the last parameter included in the request.
-
transformobject -
The transform that processes the watch payload to prepare it for the watch actions.