- Elasticsearch Guide: other versions:
- Getting Started
- Set up Elasticsearch
- Set up X-Pack
- Breaking changes
- Breaking changes in 5.5
- Breaking changes in 5.4
- Breaking changes in 5.3
- Breaking changes in 5.2
- Breaking changes in 5.1
- Breaking changes in 5.0
- Search and Query DSL changes
- Mapping changes
- Percolator changes
- Suggester changes
- Index APIs changes
- Document API changes
- Settings changes
- Allocation changes
- HTTP changes
- REST API changes
- CAT API changes
- Java API changes
- Packaging
- Plugin changes
- Filesystem related changes
- Path to data on disk
- Aggregation changes
- Script related changes
- API Conventions
- Document APIs
- Search APIs
- Aggregations
- Metrics Aggregations
- Avg Aggregation
- Cardinality Aggregation
- Extended Stats Aggregation
- Geo Bounds Aggregation
- Geo Centroid Aggregation
- Max Aggregation
- Min Aggregation
- Percentiles Aggregation
- Percentile Ranks Aggregation
- Scripted Metric Aggregation
- Stats Aggregation
- Sum Aggregation
- Top hits Aggregation
- Value Count Aggregation
- Bucket Aggregations
- Adjacency Matrix Aggregation
- Children Aggregation
- Date Histogram Aggregation
- Date Range Aggregation
- Diversified Sampler Aggregation
- Filter Aggregation
- Filters Aggregation
- Geo Distance Aggregation
- GeoHash grid Aggregation
- Global Aggregation
- Histogram Aggregation
- IP Range Aggregation
- Missing Aggregation
- Nested Aggregation
- Range Aggregation
- Reverse nested Aggregation
- Sampler Aggregation
- Significant Terms Aggregation
- Terms Aggregation
- Pipeline Aggregations
- Avg Bucket Aggregation
- Derivative Aggregation
- Max Bucket Aggregation
- Min Bucket Aggregation
- Sum Bucket Aggregation
- Stats Bucket Aggregation
- Extended Stats Bucket Aggregation
- Percentiles Bucket Aggregation
- Moving Average Aggregation
- Cumulative Sum Aggregation
- Bucket Script Aggregation
- Bucket Selector Aggregation
- Serial Differencing Aggregation
- Matrix Aggregations
- Caching heavy aggregations
- Returning only aggregation results
- Aggregation Metadata
- Returning the type of the aggregation
- Metrics Aggregations
- Indices APIs
- Create Index
- Delete Index
- Get Index
- Indices Exists
- Open / Close Index API
- Shrink Index
- Rollover Index
- Put Mapping
- Get Mapping
- Get Field Mapping
- Types Exists
- Index Aliases
- Update Indices Settings
- Get Settings
- Analyze
- Index Templates
- Shadow replica indices
- Indices Stats
- Indices Segments
- Indices Recovery
- Indices Shard Stores
- Clear Cache
- Flush
- Refresh
- Force Merge
- cat APIs
- Cluster APIs
- Query DSL
- Mapping
- Analysis
- Anatomy of an analyzer
- Testing analyzers
- Analyzers
- Normalizers
- Tokenizers
- Token Filters
- Standard Token Filter
- ASCII Folding Token Filter
- Flatten Graph Token Filter
- Length Token Filter
- Lowercase Token Filter
- Uppercase Token Filter
- NGram Token Filter
- Edge NGram Token Filter
- Porter Stem Token Filter
- Shingle Token Filter
- Stop Token Filter
- Word Delimiter Token Filter
- Word Delimiter Graph Token Filter
- Stemmer Token Filter
- Stemmer Override Token Filter
- Keyword Marker Token Filter
- Keyword Repeat Token Filter
- KStem Token Filter
- Snowball Token Filter
- Phonetic Token Filter
- Synonym Token Filter
- Synonym Graph Token Filter
- Compound Word Token Filters
- Reverse Token Filter
- Elision Token Filter
- Truncate Token Filter
- Unique Token Filter
- Pattern Capture Token Filter
- Pattern Replace Token Filter
- Trim Token Filter
- Limit Token Count Token Filter
- Hunspell Token Filter
- Common Grams Token Filter
- Normalization Token Filter
- CJK Width Token Filter
- CJK Bigram Token Filter
- Delimited Payload Token Filter
- Keep Words Token Filter
- Keep Types Token Filter
- Classic Token Filter
- Apostrophe Token Filter
- Decimal Digit Token Filter
- Fingerprint Token Filter
- Minhash Token Filter
- Character Filters
- Modules
- Index Modules
- Ingest Node
- Pipeline Definition
- Ingest APIs
- Accessing Data in Pipelines
- Handling Failures in Pipelines
- Processors
- Append Processor
- Convert Processor
- Date Processor
- Date Index Name Processor
- Fail Processor
- Foreach Processor
- Grok Processor
- Gsub Processor
- Join Processor
- JSON Processor
- KV Processor
- Lowercase Processor
- Remove Processor
- Rename Processor
- Script Processor
- Set Processor
- Split Processor
- Sort Processor
- Trim Processor
- Uppercase Processor
- Dot Expander Processor
- X-Pack APIs
- Info API
- Explore API
- Machine Learning APIs
- Close Jobs
- Create Datafeeds
- Create Jobs
- Delete Datafeeds
- Delete Jobs
- Delete Model Snapshots
- Flush Jobs
- Get Buckets
- Get Categories
- Get Datafeeds
- Get Datafeed Statistics
- Get Influencers
- Get Jobs
- Get Job Statistics
- Get Model Snapshots
- Get Records
- Open Jobs
- Post Data to Jobs
- Preview Datafeeds
- Revert Model Snapshots
- Start Datafeeds
- Stop Datafeeds
- Update Datafeeds
- Update Jobs
- Update Model Snapshots
- Security APIs
- Watcher APIs
- Definitions
- How To
- Testing
- Glossary of terms
- Release Notes
- 5.5.3 Release Notes
- 5.5.2 Release Notes
- 5.5.1 Release Notes
- 5.5.0 Release Notes
- 5.4.3 Release Notes
- 5.4.2 Release Notes
- 5.4.1 Release Notes
- 5.4.0 Release Notes
- 5.3.3 Release Notes
- 5.3.2 Release Notes
- 5.3.1 Release Notes
- 5.3.0 Release Notes
- 5.2.2 Release Notes
- 5.2.1 Release Notes
- 5.2.0 Release Notes
- 5.1.2 Release Notes
- 5.1.1 Release Notes
- 5.1.0 Release Notes
- 5.0.2 Release Notes
- 5.0.1 Release Notes
- 5.0.0 Combined Release Notes
- 5.0.0 GA Release Notes
- 5.0.0-rc1 Release Notes
- 5.0.0-beta1 Release Notes
- 5.0.0-alpha5 Release Notes
- 5.0.0-alpha4 Release Notes
- 5.0.0-alpha3 Release Notes
- 5.0.0-alpha2 Release Notes
- 5.0.0-alpha1 Release Notes
- 5.0.0-alpha1 Release Notes (Changes previously released in 2.x)
WARNING: Version 5.5 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
The execute watch API forces the execution of a stored watch. It can be used to force execution of the watch outside of its triggering logic, or to simulate the watch execution for debugging purposes.
POST _xpack/watcher/watch/<watch_id>/_execute
POST _xpack/watcher/watch/_execute
For testing and debugging purposes, you also have fine-grained control on how the watch runs. You can execute the watch without executing 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 execution.
You can use the Execute API to execute 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.
-
watch_id
- (string) Identifier for the watch.
-
debug
-
(boolean) Defines whether the watch runs in debug mode. The default value is
false
.
This API supports the following fields:
Name | Required | Default | Description |
---|---|---|---|
|
no |
This structure is parsed as the data of the trigger event that will be used during the watch execution |
|
|
no |
false |
When set to |
|
no |
null |
When present, the watch uses this object as a payload instead of executing its own input. |
|
no |
null |
Determines how to handle the watch actions as part of the watch execution. See Action Execution Modes for more information. |
|
no |
false |
When set to |
|
no |
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_execution cannot be set. |
Action modes define how actions are handled during the watch execution. There are five possible modes an action can be associated with:
Name | Description |
---|---|
|
The action execution is simulated. Each action type define its own simulation operation mode. For example, the email action creates the email that would have been sent but does not actually send it. In this mode, the action might be throttled if the current state of the watch indicates it should be. |
|
Similar to the the |
|
Executes the action as it would have been executed if the watch would have been triggered by its own trigger. The execution might be throttled if the current state of the watch indicates it should be. |
|
Similar to the |
|
The action is skipped and is not executed or simulated. Effectively forces the action to be throttled. |
You must have manage_watcher
cluster privileges to use this API. For more
information, see Security Privileges.
The following example executes the my_watch
watch:
POST _xpack/watcher/watch/my_watch/_execute
The following example shows a comprehensive example of executing the my-watch
watch:
POST _xpack/watcher/watch/my_watch/_execute { "trigger_data" : { "triggered_time" : "now", "scheduled_time" : "now" }, "alternative_input" : { "foo" : "bar" }, "ignore_condition" : true, "action_modes" : { "my-action" : "force_simulate" }, "record_execution" : true }
The triggered and schedule times are provided. |
|
The input as defined by the watch is ignored and instead the provided input is used as the execution payload. |
|
The condition as defined by the watch is ignored and is assumed to
evaluate to |
|
Forces the simulation of |
|
The execution of the watch creates a watch record in the watch history, and the throttling state of the watch is potentially updated accordingly. |
This is an example of the output:
{ "_id": "my_watch_0-2015-06-02T23:17:55.124Z", "watch_record": { "watch_id": "my_watch", "messages": [], "trigger_event": { "type": "manual", "triggered_time": "2015-06-02T23:17:55.124Z", "manual": { "schedule": { "scheduled_time": "2015-06-02T23:17:55.124Z" } } }, "state": "executed", "_status": { "state": { "active": true, "timestamp": "2015-06-02T23:17:55.111Z" }, "last_checked": "2015-06-02T23:17:55.124Z", "last_met_condition": "2015-06-02T23:17:55.124Z", "actions": { "test_index": { "ack": { "timestamp": "2015-06-02T23:17:55.124Z", "state": "ackable" }, "last_execution": { "timestamp": "2015-06-02T23:17:55.124Z", "successful": true }, "last_successful_execution": { "timestamp": "2015-06-02T23:17:55.124Z", "successful": true } } } }, "input": { "simple": { "payload": { "send": "yes" } } }, "condition": { "always": {} }, "result": { "execution_time": "2015-06-02T23:17:55.124Z", "execution_duration": 12608, "input": { "type": "simple", "payload": { "foo": "bar" }, "status": "success" }, "condition": { "type": "always", "met": true, "status": "success" }, "actions": [ { "id": "test_index", "index": { "response": { "index": "test", "type": "test2", "version": 1, "created": true, "result": "created", "id": "AVSHKzPa9zx62AzUzFXY" } }, "status": "success", "type": "index" } ] } } }
The id of the watch record as it would be stored in the |
|
The watch record document as it would be stored in the |
|
The watch execution results. |
You can set a different execution mode for every action by associating the mode name with the action id:
POST _xpack/watcher/watch/my_watch/_execute { "action_modes" : { "action1" : "force_simulate", "action2" : "skip" } }
You can also associate a single execution mode with all the actions in the watch
using _all
as the action id:
POST _xpack/watcher/watch/my_watch/_execute { "action_modes" : { "_all" : "force_execute" } }
The following example shows how to execute a watch inline:
POST _xpack/watcher/watch/_execute { "watch" : { "trigger" : { "schedule" : { "interval" : "10s" } }, "input" : { "search" : { "request" : { "indices" : [ "logs" ], "body" : { "query" : { "match" : { "message": "error" } } } } } }, "condition" : { "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }} }, "actions" : { "log_error" : { "logging" : { "text" : "Found {{ctx.payload.hits.total}} errors in the logs" } } } } }
All other settings for this API still apply when inlining a watch. In the
following snippet, while the inline watch defines a compare
condition,
during the execution this condition will be ignored:
POST _xpack/watcher/watch/_execute { "ignore_condition" : true, "watch" : { "trigger" : { "schedule" : { "interval" : "10s" } }, "input" : { "search" : { "request" : { "indices" : [ "logs" ], "body" : { "query" : { "match" : { "message": "error" } } } } } }, "condition" : { "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }} }, "actions" : { "log_error" : { "logging" : { "text" : "Found {{ctx.payload.hits.total}} errors in the logs" } } } } }
On this page