When you add a watch, Watcher immediately registers its trigger with the appropriate trigger
engine. Watches that have a
schedule trigger are registered with the
scheduler trigger engine.
The trigger engine is responsible for triggering execution of the watch. Trigger engines run on
the master node and use a separate thread pool from the one used to execute watches.
When a watch is triggered, Watcher queues it up for execution. A
watch_record document is
created and added to the watch history index and the initial status is set to
When execution starts, Watcher creates a watch execution context for the watch. The execution context provides scripts and templates access to the watch metadata, payload, watch ID, execution time, and trigger information. For more information, see Watch Execution Context.
During the execution process, Watcher:
- Loads the input data into the payload in the watch execution context. This makes the data available to all subsequent steps in the execution process. This step is controlled by the input configured for the watch.
Evaluates the watch condition to determine whether or not to continue processing the watch.
If the condition is met (evaluates to
true), processing advances to the next step. If it is not met (evaluates to
false), execution of the watch stops.
- Applies transforms to the watch payload (if defined).
- Executes the watch actions if the condition is met and the watch is not being throttled.
When watch execution finishes, Watcher updates the watch record with the execution results. The watch record includes the execution time and duration, whether the watch condition was met, and the status of each action that was performed. For more information, see Watch History.
The following diagram shows the watch execution process: