Run a watch
- POST also PUT /_watcher/watch/{id}/_execute
- POST also PUT /_watcher/watch/_execute
This API can be used to force execution of the watch outside of its triggering logic or to simulate the watch execution for debugging purposes.
For testing and debugging purposes, you also have fine-grained control on how the watch runs. You can run the watch without running all of its actions or alternatively by simulating them. You can also force execution by ignoring the watch condition and control whether a watch record would be written to the watch history after it runs.
You can use the run watch API to run watches that are not yet registered by specifying the watch definition inline. This serves as great tool for testing and debugging your watches prior to adding them to Watcher.
When Elasticsearch security features are enabled on your cluster, watches are run with the privileges of the user that stored the watches.
If your user is allowed to read index a, but not index b, then the exact same set of rules will apply during execution of a watch.
When using the run watch API, the authorization data of the user that called the API will be used as a base, instead of the information who stored the watch.
- Cluster privileges:
manage_watcher
Path Parameters
-
idstring Idoptional -
The watch identifier.
Leave it out to use
/_watcher/watch/_execute.
Query Parameters
-
debugboolean · default: false Defines whether the watch runs in debug mode.
Request
-
action_modesmap string to ActionExecutionMode -
Determines how to handle the watch actions as part of the watch execution.
-
alternative_inputmap string to object -
When present, the watch uses this object as a payload instead of executing its own input.
-
ignore_conditionboolean · default: false -
When set to
true, the watch execution uses the always condition. This can also be specified as an HTTP parameter. -
record_executionboolean · default: false -
When set to
true, the watch record representing the watch execution result is persisted to the.watcher-historyindex for the current time. In addition, the status of the watch is updated, possibly throttling subsequent runs. This can also be specified as an HTTP parameter. -
simulated_actionsSimulatedActions -
trigger_dataScheduleTriggerEvent -
This structure is parsed as the data of the trigger event that will be used during the watch execution.
-
scheduled_timeDateTimerequired -
triggered_timeDateTime -
watchWatch · default: null -
When present, this watch is used instead of the one specified in the request. This watch is not persisted to the index and
record_executioncannot be set. -
actionsmap string to Actionrequired -
<string>Action -
action_typeActionType -
Values:
emailwebhookindexloggingslackpagerduty -
conditionConditionContainer -
foreachstring -
max_iterationsnumber -
namestring Name -
throttle_periodstring Duration -
throttle_period_in_millisDurationValueUnitMillis -
transformTransformContainer -
chainTransformContainer -
scriptScriptTransform -
searchSearchTransform -
requestSearchInputRequestDefinitionrequired -
bodySearchInputRequestBody -
queryQueryContainerrequired -
indicesstring IndexName -
indices_optionsIndicesOptions -
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 ExpandWildcards -
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.
-
ignore_throttledboolean · default: true -
If true, concrete, expanded or aliased indices are ignored when frozen.
-
search_typeSearchType -
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 -
templateSearchTemplateRequestBody -
explainboolean · default: false -
idstring Id -
ID of the search template to use. If no source is specified, this parameter is required.
-
paramsmap string to object -
profileboolean · default: false -
sourcestring -
An inline search template. Supports the same parameters as the search API's request body. Also supports Mustache variables. If no id is specified, this parameter is required.
-
rest_total_hits_as_intboolean -
timeoutstring Durationrequired -
indexIndexAction -
indexstring IndexNamerequired -
doc_idstring Id -
refreshRefresh -
Values:
truefalsewait_for -
op_typeOpType · default: index -
Supported values include:
index: Overwrite any documents that already exist.create: Only index documents that do not already exist.
-
Values:
indexcreate -
timeoutstring Duration · default: 60s -
execution_time_fieldstring Field -
emailEmailAction -
idstring Id -
bccstring | string -
ccstring | string -
fromstring -
priorityEmailPriority -
Values:
lowestlownormalhighhighest -
reply_tostring | string -
sent_dateDateTime -
subjectstringrequired -
tostring | stringrequired -
attachmentsmap string to EmailAttachmentContainer -
<string>EmailAttachmentContainer -
httpHttpEmailAttachment -
content_typestring -
inlineboolean -
requestHttpInputRequestDefinition -
authHttpInputAuthentication -
bodystring -
connection_timeoutstring Duration -
headersmap string to string -
hoststring -
methodHttpInputMethod -
Values:
headgetpostputdelete -
paramsmap string to string -
pathstring -
portnumber uint -
read_timeoutstring Duration -
schemeConnectionScheme -
Values:
httphttps -
urlstring -
reportingReportingEmailAttachment -
pagerdutyPagerDutyAction -
accountstring -
attach_payloadbooleanrequired -
clientstring -
client_urlstring -
contextsPagerDutyContext -
descriptionstringrequired -
event_typePagerDutyEventType · default: trigger -
Values:
triggerresolveacknowledge -
incident_keystringrequired -
slackSlackAction -
accountstring -
messageSlackMessagerequired -
attachmentsSlackAttachmentrequired -
dynamic_attachmentsSlackDynamicAttachment -
attachment_templateSlackAttachmentrequired -
list_pathstringrequired -
fromstringrequired -
iconstring -
textstringrequired -
tostringrequired -
webhookWebhookAction -
authHttpInputAuthentication -
bodystring -
connection_timeoutstring Duration -
headersmap string to string -
hoststring -
methodHttpInputMethod -
Values:
headgetpostputdelete -
paramsmap string to string -
pathstring -
portnumber uint -
read_timeoutstring Duration -
schemeConnectionScheme -
Values:
httphttps -
urlstring -
conditionConditionContainerrequired -
inputInputContainerrequired -
metadataMetadata -
statusWatchStatus -
actionsActionsrequired -
last_checkedDateTime -
last_met_conditionDateTime -
versionnumber VersionNumberrequired -
execution_statestring -
throttle_periodstring Duration -
throttle_period_in_millisDurationValueUnitMillis -
transformTransformContainer -
triggerTriggerContainerrequired
Response
-
_idstring Idrequired -
The watch record identifier as it would be stored in the
.watcher-historyindex. -
watch_recordWatchRecordrequired -
The watch record document as it would be stored in the
.watcher-historyindex. -
conditionConditionContainerrequired -
inputInputContainerrequired -
messagesstringrequired -
metadataMetadata -
nodestringrequired -
resultExecutionResultrequired -
actionsExecutionResultActionrequired -
emailEmailResult -
accountstring -
messageEmailrequired -
idstring Id -
bccstring | string -
ccstring | string -
fromstring -
priorityEmailPriority -
Values:
lowestlownormalhighhighest -
reply_tostring | string -
sent_dateDateTime -
subjectstringrequired -
tostring | stringrequired -
attachmentsmap string to EmailAttachmentContainer -
<string>EmailAttachmentContainer -
reasonstring -
idstring Idrequired -
indexIndexResult -
loggingLoggingResult -
logged_textstringrequired -
pagerdutyPagerDutyResult -
eventPagerDutyEventrequired -
accountstring -
attach_payloadbooleanrequired -
clientstring -
client_urlstring -
contextsPagerDutyContext -
descriptionstringrequired -
event_typePagerDutyEventType · default: trigger -
Values:
triggerresolveacknowledge -
incident_keystringrequired -
reasonstring -
requestHttpInputRequestResult -
authHttpInputAuthentication -
bodystring -
connection_timeoutstring Duration -
headersmap string to string -
hoststring -
methodHttpInputMethod -
Values:
headgetpostputdelete -
paramsmap string to string -
pathstring -
portnumber uint -
read_timeoutstring Duration -
schemeConnectionScheme -
Values:
httphttps -
urlstring -
reasonstring -
statusActionStatusOptionsrequired -
Values:
successfailuresimulatedthrottled -
typeActionTyperequired -
Values:
emailwebhookindexloggingslackpagerduty -
webhookWebhookResult -
errorErrorCause -
typestringrequired -
The type of error
-
reasonstringnullable -
A human-readable explanation of the error, in English.
-
stack_tracestring -
The server stack trace. Present only if the
error_trace=trueparameter was sent with the request. -
caused_byErrorCause -
root_causeErrorCause -
suppressedErrorCause -
conditionExecutionResultConditionrequired -
execution_durationDurationValueUnitMillisrequired -
execution_timeDateTimerequired -
stateExecutionStatusrequired -
Values:
awaits_executioncheckingexecution_not_neededthrottledexecutedfaileddeleted_while_queuednot_executed_already_queued -
trigger_eventTriggerEventResultrequired -
manualTriggerEventContainerrequired -
scheduleScheduleTriggerEvent -
scheduled_timeDateTimerequired -
triggered_timeDateTime -
triggered_timeDateTimerequired -
typestringrequired -
userstringrequired -
watch_idstring Idrequired -
statusWatchStatus -
actionsActionsrequired -
last_checkedDateTime -
last_met_conditionDateTime -
versionnumber VersionNumberrequired -
execution_statestring