elasticsearch/docs/reference/watcher/trigger/schedule.asciidoc
Luke Whiting 1d4c8d85f6
(#34659) - Add Timezone Configuration to Watcher (#117033)
* Add timezone support to Cron objects

* Add timezone support to CronnableSchedule

* XContent change to support parsing and display of TimeZone fields on schedules

* Case insensitive timezone parsing

* Doc changes

* YAML REST tests

* Equals, toString and HashCode now include timezone

* Additional random testing for DST transitions

* Migrate Cron class to use wrapped LocalDateTime

The algorithm depends on some quirks of calendar but LocalDateTime
correctly ignores DST during calculations so this uses a LocalDateTime
with a wrapper to emulate some of Calendar's behaviours that the Cron
algorithm depends on

* Additional documentation to explain discontinuity event behaviour

* Remove redundant conversions from ZoneId to TimeZone following move to LocalDateTime

* Add documentation warning that manual clock changes will cause unpredictable watch execution

* Update docs/reference/watcher/trigger/schedule.asciidoc

Co-authored-by: Lee Hinman <dakrone@users.noreply.github.com>

---------

Co-authored-by: Lee Hinman <dakrone@users.noreply.github.com>
2024-11-25 09:51:11 +00:00

76 lines
3.2 KiB
Text

[role="xpack"]
[[trigger-schedule]]
=== {watcher} schedule trigger
++++
<titleabbrev>Schedule trigger</titleabbrev>
++++
Schedule <<trigger,triggers>> define when the watch execution should start based
on date and time. All times are in UTC time unless a timezone is explicitly specified
in the schedule.
{watcher} uses the system clock to determine the current time. To ensure schedules
are triggered when expected, you should synchronize the clocks of all nodes in the
cluster using a time service such as http://www.ntp.org/[NTP].
NOTE: {watcher} can't correct for manual adjustments to the system clock. Be aware when making
such changes that watch execution may be affected with watches being skipped or repeated if the
adjustment covers their target execution time. This applies to changes made via NTP as well.
When specifying a timezone for a watch, keep in mind the effect daylight savings time
transitions may have on the schedule, especially if the watch is scheduled to run
during the transition. Here's how {watcher} handles watches scheduled during discontinuities:
==== Gap Transitions
These occur when the clock moves forward, such as when daylight savings time starts
and cause certain hours or minutes to be skipped. If your watch is scheduled to run
during a gap transition, the watch is executed at the same time as before the transition.
Example: If a watch is scheduled to run daily at 1:30AM in the `Europe/London` time zone and
the clock moves forward one hour from 1:00AM (GMT+0) to 2:00AM (GMT+1), the watch is executed
at 2:30AM (GMT+1) which would have been 1:30AM before the transition. Subsequent executions
happen at 1:30AM (GMT+1).
==== Overlap Transitions
These occur when the clock moves backward, such as when daylight savings time ends
and cause certain hours or minutes to be repeated. If your watch is scheduled to run
during an overlap transition, only the first occurrence of the time causes to the watch
to execute with the second being skipped.
Example: If a watch is scheduled to run at 1:30 AM and the clock moves backward one hour
from 2:00AM to 1:00AM, the watch is executed at 1:30AM and the second occurrence after the
change is skipped.
=== Throttling
Keep in mind that the throttle period can affect when a watch is actually executed.
The default throttle period is five seconds (5000 ms). If you configure a schedule
that's more frequent than the throttle period, the throttle period overrides the
schedule. For example, if you set the throttle period to one minute (60000 ms)
and set the schedule to every 10 seconds, the watch is executed no more than
once per minute. For more information about throttling, see
<<actions-ack-throttle>>.
=== Schedule Types
{watcher} provides several types of schedule triggers:
* <<schedule-hourly, `hourly`>>
* <<schedule-daily, `daily`>>
* <<schedule-weekly, `weekly`>>
* <<schedule-monthly, `monthly`>>
* <<schedule-yearly, `yearly`>>
* <<schedule-cron, `cron`>>
* <<schedule-interval, `interval`>>
include::schedule/hourly.asciidoc[]
include::schedule/daily.asciidoc[]
include::schedule/weekly.asciidoc[]
include::schedule/monthly.asciidoc[]
include::schedule/yearly.asciidoc[]
include::schedule/cron.asciidoc[]
include::schedule/interval.asciidoc[]