Watcher: Alerting in Elasticsearch

Watcher: Alerting in Elasticsearch

How Elasticsearch watches your data around the clock and taps you on the shoulder when something needs attention: what a watch is, how it runs inside the cluster, how to design alerts people trust, and where alerting goes wrong.

Picture a night guard at a large warehouse. He does not stare at every shelf all night. Instead, he walks a fixed route every few minutes, checks a few important things (Is that door locked? Is the freezer cold enough? Is anyone in the loading bay?), and if something looks wrong, he picks up a radio and calls the right person. He also knows not to call the manager twelve times about the same open door. In Elasticsearch, Watcher is that guard. It walks a route you define, asks your data a question on a schedule, decides whether the answer is worrying, and sends a message to the right place when it is.

1The Problem: Nobody Can Stare at Dashboards Forever

Storing and searching data is only half the value. The other half is knowing, without asking, when the data says something important.

Data that changes all day and night

Modern systems produce a constant stream of facts: web requests, payments, login attempts, temperature readings, error messages, disk usage numbers. Elasticsearch is very good at keeping all of this and answering questions about it. But a question only gets answered when somebody asks it. If nobody is looking at the dashboard when the error rate triples at three in the morning, the problem grows quietly until customers notice.

People are not built to watch screens all day. They sleep, they take lunch, they attend meetings, and they get tired of looking at charts that are normal ninety-nine percent of the time. The sensible answer is to teach the computer to ask the question on a regular basis and to speak up only when the answer is worrying.

What good alerting gives you

24/7
Coverage without a person staring at a screen
Minutes
Time to notice a problem instead of hours
1 message
Sent to the right person, not fifty to everyone
Simple Analogy

A smoke detector does not watch your kitchen the way a cook does. It sits quietly, checks the air over and over, and stays silent for years. The one time it senses smoke, it makes a very loud noise. Its value is not in what it does most of the time. Its value is in the single moment that matters.

The two ways alerting can fail

Alerting can fail by being too quiet or too loud. A too-quiet system misses a real fire. A too-loud system cries wolf so often that people mute it, and then it also misses the real fire, because nobody is listening anymore. A large part of this guide is about walking the line between those two failures.

FailureWhat it looks likeWhat it costs
Missed alertA real outage happens and nobody is toldDowntime, lost sales, angry customers
Noisy alertThe same warning arrives every minute for hoursFatigue, muted channels, ignored messages
Late alertThe message arrives after the damage is doneSlow response, bigger impact
Vague alert“Something is wrong” with no detailsWasted time finding the cause
Orphan alertNobody owns it or knows what to doWarnings that sit unread
i
Key Idea

A good alert is a small story: what happened, how bad it is, since when, and what to look at first. The rest of the design of an alerting system exists to make that small story arrive at the right time and in the right place.

2Foundations You Need First

Watcher borrows from several ideas you may already know. Getting comfortable with them makes everything else easier.

Searches and aggregations

Elasticsearch stores documents in indices. A search asks for documents that match some conditions, such as “all log lines from the checkout service in the last five minutes that contain the word error”. An aggregation summarizes matching documents, such as “how many per minute” or “the average response time per server”. Most alerts are built from exactly this kind of question, asked again and again.

Kinds of alert conditions

Type 1

Threshold

Something crosses a line: more than fifty errors in five minutes, or disk usage above ninety percent.

Type 2

Absence

Something that should happen did not: no heartbeat from a service, or no orders in the last ten minutes.

Type 3

Change

Something moved suddenly compared with before: traffic dropped by half compared with the same hour yesterday.

Type 4

Pattern

A meaningful combination appeared: many failed logins from one address followed by one success.

Type 5

Anomaly

A statistical model says a value is unusual for its normal behavior, even without a fixed threshold.

Time windows and schedules

Every alert is based on a window of time. A watch that asks “how many errors ever?” is useless, because the answer only grows. A watch that asks “how many errors in the last five minutes?” answers a fair, repeatable question. The schedule (how often you ask) and the window (how far back you look) are two separate choices, and they work together. If you ask every minute but look back five minutes, each error is counted several times. That is fine for a threshold alert, but it can be confusing if you want to count events exactly once.

Notification channels

An alert is only useful if it reaches a person or a system. Common destinations are email, chat tools such as Slack, paging services such as PagerDuty, ticketing systems such as Jira, and generic web endpoints that let you connect anything else. Watcher includes built-in ways to talk to these, and it can also write the alert itself back into an Elasticsearch index, so you have a record.

Templates

Messages are rarely fixed text. You want the message to say “The checkout service had 87 errors in the last five minutes”, with the real number filled in. Watcher uses a simple templating language, called Mustache, that lets a message pull values out of the search results and the watch itself. You will see later how the same watch produces different messages depending on the data it found.

Simple Analogy

A template is like a form letter with blanks: “Dear ____, your package will arrive on ____.” The blanks are filled in by whatever the data says at that moment, so one letter design can serve thousands of different situations.

flowchart LR
  A[Data arrives in Elasticsearch] --> B[Question asked on a schedule]
  B --> C{Is the answer worrying?}
  C -->|No| D[Stay quiet]
  C -->|Yes| E[Send message to a channel]
        
FIG 1 — The basic idea behind every alerting system

3So, What Is Watcher?

Watcher is the alerting and notification feature built into Elasticsearch itself.

The short definition

Watcher lets you create watches. A watch is a stored job that runs on a schedule inside the Elasticsearch cluster. Each time it runs, it collects some data (usually by running a search), checks a condition on that data, and, if the condition is true, carries out one or more actions such as sending an email or posting to a chat channel. Because it lives inside the cluster, it needs no extra server and it can ask questions of your data directly, with no export step.

“A watch is a question you ask your data every few minutes, together with instructions for what to do about the answer.”

Where it came from

Watcher began years ago as a separate plugin for Elasticsearch and later became part of the commercial feature set of the Elastic Stack, sitting alongside features like security and monitoring. Today its code ships inside Elasticsearch, and it is switched on or off by settings and by your license. Because the Elastic Stack has evolved, Kibana now also offers its own alerting framework with rules and connectors. Both exist, and this guide compares them later so you can choose between them with your eyes open.

What makes it different from a script and a timer

You could write your own script that runs every five minutes, queries Elasticsearch, and sends an email. Many people did before Watcher existed. Watcher gives you that same idea with several things already solved: it runs in the cluster and survives node failures, it stores its own history so you can see what happened, it can suppress repeats so people are not flooded, it has a testing tool, and it uses the same security system as the rest of Elasticsearch.

Feature

Runs inside the cluster

No external scheduler to maintain. Watches are stored as data in a system index and spread across nodes.

Feature

Flexible queries

Any search or aggregation Elasticsearch can perform can feed an alert, including across many indices.

Feature

Built-in actions

Email, chat, paging, ticketing, web calls, index writes, and log lines are included.

Feature

Throttling and acknowledgement

Tools to stop the same alert from repeating endlessly and to let a person say “I have seen this”.

Feature

Execution history

Every run is recorded, so you can audit what was checked, what was found, and what was sent.

Feature

Test without sending

An execute tool lets you run a watch on demand and simulate the actions to check the result safely.

!
Licensing Note

Watcher is a subscription feature and is not included in the free basic license. It requires a paid tier or an active trial. Features and licensing change between releases, so confirm the details in the documentation for your exact version before you plan a project around it.

What Watcher is not

Watcher is not a full incident management system. It does not schedule on-call rotations, group related alerts into a single case, or track who fixed what. It sends messages to systems that do those jobs. Watcher is also not a stream processor: it looks at data on a schedule rather than reacting the instant a single document arrives, so it suits problems measured in minutes rather than milliseconds.

4The Anatomy of a Watch

Every watch is built from the same five building blocks. Learn them once and you can read any watch.

Block 1

Trigger

When to run. A schedule such as every minute, every day at nine, or a custom calendar pattern.

Block 2

Input

What data to load. Usually the result of a search, but it can also be a fixed value or a call to a web service.

Block 3

Condition

Whether to continue. A test on the loaded data that decides if the actions should run.

Block 4

Transform

Optional reshaping. Prepare or trim the data so the actions receive exactly what they need.

Block 5

Actions

What to do. Send a message, call a service, write a document, or add a line to a log.

Extra

Metadata and throttle

Free-form labels you can reuse in messages, and rules that limit how often actions may fire.

flowchart LR
  T[Trigger fires] --> I[Input loads data]
  I --> C{Condition}
  C -->|False| X[Stop and record]
  C -->|True| TR[Transform optional]
  TR --> A[Actions run]
  A --> H[History recorded]
  X --> H
        
FIG 2 — The five blocks and the order in which they run
Simple Analogy

Think of a doorbell camera set up by a careful homeowner. The trigger is the timer that wakes it every minute. The input is the photo it takes. The condition is “is there a person in the picture?”. The transform is cropping the photo to the person. The action is sending that cropped photo to your phone. If there is nobody at the door, it does nothing more.

A watch is just data

A watch is a JSON document stored in a system index. That means you can create, read, update, and delete watches through the same kind of API calls you use for any other Elasticsearch data. It also means you can keep watches in version control, review them like any other configuration, and deploy them with automation. Kibana offers a user interface for creating simple watches and for editing the raw definition of advanced ones.

The watch record and the watch status

Alongside the definition, each watch has a status section that Watcher maintains itself. It records whether the watch is active, when it last ran, when its condition was last met, and the state of each action (for example, whether it has been acknowledged). You do not edit this by hand. It is how Watcher remembers what it has already done between runs, which is the key to avoiding duplicate alerts.

i
Naming Tip

Give each watch a clear identifier and human-readable description that says what it protects and who owns it. Six months later, “checkout-error-rate-payments-team” will save you a lot of digging that “watch-17” never will.

5Triggers: Deciding When a Watch Runs

The trigger answers one question: how often should we look?

Schedule triggers

Watcher supports a schedule trigger. It comes in several flavors, from simple to precise.

StyleMeaningGood for
IntervalRun every fixed amount of time, such as every thirty seconds or every five minutesLive health checks and error rates
HourlyRun at chosen minutes past each hourRegular summaries
DailyRun at one or more chosen times of the dayMorning reports and end-of-day checks
Weekly and monthlyRun on chosen days at chosen timesBusiness reviews and periodic audits
YearlyRun on chosen dates each yearRare, calendar-driven jobs
CronA flexible expression that describes complex calendarsWorking-hours-only checks and unusual patterns

Choosing an interval

The natural temptation is to make everything run every second, so nothing is missed. This is almost always a mistake. Each run costs a search, and thousands of searches per minute across many watches can load the cluster more than the problem they are watching. Choose an interval that matches how quickly someone must react. If a person will take at least ten minutes to respond, checking every minute is already generous. If the alert protects something that must be noticed within seconds, consider whether a different tool is the right choice.

Simple Analogy

A lifeguard scanning the pool every few seconds makes sense, because a swimmer in trouble has little time. A gardener checking whether the soil is dry every few seconds would be silly, because plants take hours to change. Match the checking speed to how fast the thing you watch can go wrong.

Scheduled time versus triggered time

Every run carries two timestamps. The scheduled time is when the run was supposed to happen. The triggered time is when it actually started. They usually differ by only a moment, but if the cluster is busy, the difference can grow. Good watches base their search windows on the scheduled time, not on the current clock, so that a delayed run still looks at the correct slice of history and does not skip or double-count data.

Time zones and calendars

Calendar-style schedules such as daily at nine in the morning depend on a time zone. Confirm which time zone your version uses, and remember that the people receiving reports may live in another. Daylight saving changes can also shift which hour a job seems to run in. For anything where a wrong hour matters, test the schedule and check the recorded trigger times after it first runs.

Manual runs

Besides the schedule, you can trigger a watch manually with the execute tool. This is what you use while building and testing. It runs the watch right now, optionally ignoring the condition or simulating the actions, and it returns a full record of what happened without waiting for the clock.

!
Common Mistake

Setting a schedule that is faster than the watch can finish. If a search takes forty seconds and the interval is thirty seconds, runs queue up behind each other and the system falls behind. Always measure how long a watch takes before deciding how often it should run.

6Inputs: Loading the Data

The input gathers the facts the watch will judge. Four kinds exist, and they can be combined.

Input

Simple

Loads a fixed piece of data written into the watch itself. Handy for testing, and for passing constants to later steps.

Input

Search

Runs an Elasticsearch search over chosen indices and loads the response. The most common input by far.

Input

HTTP

Calls a web address, such as an internal service or another Elasticsearch cluster, and loads the reply.

Input

Chain

Runs several inputs in order, so a later one can use the result of an earlier one.

The search input in depth

The search input lets you name the indices (patterns are allowed), and provide a full search request body. You can filter by time, aggregate, sort, and pick which fields to return. The search body may include templated pieces, so it can refer to the scheduled time of the run. This is how a watch says “the five minutes before this run” without hard-coding any dates.

Because the whole search response becomes the input, it can be large. If your alert only cares about a count, ask for a count and request no hits at all. Returning thousands of documents that the condition never looks at wastes memory and time.

The HTTP input

The HTTP input reaches beyond Elasticsearch. For example, a watch can ask a status page for the health of a partner service, or ask another cluster for its statistics. Because it makes outbound calls, it deserves extra care: allow only the addresses you intend, keep credentials in the secure store rather than in the watch text, and set sensible time limits so a slow service cannot stall the watch.

Chaining inputs

A chain lets you build a small pipeline. The first step might find the busiest server in the last hour. The second step might then ask for the error counts of that particular server. The result of each step is available to later steps by name. This is powerful but easy to overuse. If a chain grows longer than two or three steps, consider whether the logic belongs in a dedicated application instead.

flowchart TD
  S[Scheduled run] --> IN{Input type}
  IN --> A[Simple: fixed data]
  IN --> B[Search: query an index]
  IN --> C[HTTP: call a web service]
  IN --> D[Chain: several in order]
  A --> P[Payload passed to condition]
  B --> P
  C --> P
  D --> P
        
FIG 3 — Whatever the input, the result becomes the payload for the next step
i
Practical Tip

Design the search to return the smallest answer that lets the condition decide. A single number is better than a thousand documents. You can always run a second, more detailed search after the condition is true, to gather details for the message.

7Conditions and Transforms

The condition is the judge. The transform is the editor. Together they decide whether to speak and what to say.

Condition types

ConditionMeaningTypical use
AlwaysAlways true, so actions always runScheduled reports that must be sent no matter what
NeverAlways false, so actions never runTemporarily muting a watch without deleting it
CompareCompares one value in the data to a fixed valueSimple thresholds, such as count greater than fifty
Array compareChecks whether items in a list match a comparison, and how many“Any server with disk above ninety percent”
ScriptRuns a small script that returns true or falseLogic too complex for the simple forms

Thinking about thresholds

Choosing the line is harder than writing it. A threshold that is too low fires at every small bump. One that is too high fires only after the damage is done. Start by looking at a few weeks of historical data to learn what normal looks like, including daily and weekly rhythms. A shop has more traffic at lunchtime than at four in the morning, so a single fixed error count may be a good alert at night and a constant nuisance at noon.

Two common improvements help. One is to compare the current window to a matching window in the past, such as this hour compared with the same hour last week. The other is to require that the bad condition has lasted for several consecutive runs before alerting, which filters out one-off spikes.

Simple Analogy

A room thermostat with no tolerance would switch the heating on and off every few seconds as the temperature wobbles around the target. Real thermostats allow a small gap so they change state only when the temperature has really moved. Alert thresholds work better with the same idea of a buffer zone.

Scripts as conditions

The script condition gives you full flexibility, for example checking that at least three of five services are unhealthy, or that a ratio between two aggregations passes a limit. The price is readability and safety. Scripts are harder to review, easier to get subtly wrong, and run inside the cluster, so keep them short and test them well. Prefer the simple condition types when they are enough.

Transforms

A transform sits between the condition and the actions. It changes the payload, the working data, before the actions see it. There are three forms: a search transform that replaces the payload with the result of a new search, a script transform that reshapes the data with code, and a chain that applies several transforms in order.

A very useful pattern is to keep the first search cheap (just a count), and use a search transform only when the condition is true to fetch a handful of example documents to show in the message. That way, the expensive detail is gathered only when it is actually needed. Transforms can also be defined separately for each action, so the email can carry a long explanation while the chat message carries one short line.

Example: Two-stage alert

Stage one counts the error messages in the last five minutes. If the count is above the limit, the transform fetches the three most common error messages and the top affected servers. The action then sends a message that says, “87 errors in five minutes, mostly a timeout calling the payment service on servers A and B.” The reader knows where to start without opening a dashboard.

8Actions: Telling the World

Actions are where alerting turns into something a human can read. A single watch can have several actions, each with its own settings.

Action

Email

Sends a message through a configured mail server. Good for reports and for alerts that are important but not urgent.

Action

Slack

Posts a message to a chat channel. Good for team awareness and quick discussion.

Action

PagerDuty

Creates an incident in a paging service, so the on-call person is woken up.

Action

Jira

Creates a ticket in a work tracker, useful for issues that need follow-up but not immediate action.

Action

Webhook

Calls any web address with a message. The universal connector for chat tools, automation platforms, and home-grown services.

Action

Index

Writes a document into an Elasticsearch index, creating a searchable record of every alert.

Action

Logging

Writes a line to the Elasticsearch server log. Useful for debugging and for very simple setups.

Building good messages

Messages are templates. They can include the number that triggered the alert, the time window, the name of the watch, and values you stored as metadata. A good message answers four questions in the first lines: what is wrong, how bad is it, since when, and where should I look? A link to the relevant dashboard or the exact search is worth more than a paragraph of explanation.

1

Lead with the impact

“Checkout errors are 6 times higher than normal” is clearer than “Threshold exceeded on watch 42”.

2

State the numbers

Include the measured value, the limit, and the time window so the reader can judge severity at a glance.

3

Point to the next step

Add a link to a dashboard, a saved search, or a runbook page that says what to check first.

4

Name the owner

Say which team is responsible, or route the message to that team’s own channel.

Configuring the channels

Each channel needs to be set up on the Elasticsearch nodes before a watch can use it. Email needs mail server details. Slack and PagerDuty need account details, such as a webhook address or a service key. These secrets belong in the secure settings store of each node rather than in plain configuration files or in the watch text itself. Once an account has a name, watches refer to it by that name, so you can rotate a secret in one place.

Per-action control

Each action can have its own condition, transform, and throttle. This allows tiered alerting inside one watch: a warning to a chat channel when the error count passes fifty, and a page to the on-call engineer only when it passes two hundred. It is often cleaner than creating separate watches that repeat the same search.

!
Do Not Forget

Watcher does not retry failed notifications forever. If the mail server is down at the moment the action runs, the failure is recorded in the history, but the message may simply be lost. For critical alerts, use a paging service with its own reliability guarantees and also monitor for failed actions.

9Architecture and Components

Watcher is not a separate server. It is a set of components inside each Elasticsearch node. Knowing what they are explains most of its behavior.

Storage

Watches index

A system index that stores the definition and status of every watch. Its shards decide which nodes are responsible for which watches.

Storage

Triggered watches index

A system index holding runs that have started but not yet finished, so they can be resumed after a failure.

Storage

Watch history indices

Time-based indices that keep a record of every execution: what ran, what was found, and what actions were taken.

Engine

Trigger engine

The scheduler on each node. It knows the schedules of the watches on its shards and fires them at the right moments.

Engine

Execution service

Runs the input, condition, transform, and actions of a triggered watch, using a dedicated pool of threads.

Engine

Watcher service state

A master switch that can be started, stopped, and inspected. It is either running or not, across the whole cluster.

flowchart TD
  U[Watch stored via API or Kibana] --> W[(Watches index)]
  W --> N1[Node 1: shard copy and scheduler]
  W --> N2[Node 2: shard copy and scheduler]
  N1 --> Q[Execution thread pool]
  N2 --> Q
  Q --> S[Search on data indices]
  Q --> ACT[Actions to email, chat, web]
  Q --> HI[(Watch history index)]
        
FIG 4 — The main components of Watcher and how a run moves through them

How work is spread across the cluster

Each watch document lives in a shard of the watches index. The node that holds a shard copy is responsible for scheduling the watches stored on that shard. This means the work of firing triggers is spread naturally across the nodes that hold the shards, and no single scheduler node is required. The watches index is configured so that copies are available on the nodes that need them, which lets a surviving node pick up the schedules of a failed one.

Simple Analogy

Imagine a large office where each receptionist keeps a diary of the appointments for their own set of clients. Nobody has one master diary. If one receptionist goes home sick, a colleague holding a copy of that diary takes over their calls. The alarm clock of each appointment lives with whoever holds the diary.

Which nodes should run Watcher?

Watches execute on data nodes that hold copies of the watches index. Because each run performs searches and calls other systems, heavy watcher workloads compete with the searches and indexing that those data nodes already do. In large clusters, plan capacity with this in mind, and avoid placing the watches index on the weakest nodes in the cluster.

The thread pool

Executions run in a dedicated thread pool with a bounded queue. When many watches fire at the same moment, the extra runs wait in the queue. If the queue fills up, further runs can be rejected and recorded as such. This is a safety valve. It stops a flood of alerts from overwhelming the node, but it also means that a badly overloaded cluster may skip or delay alerts precisely when you need them most.

10Internal Working: The Life of One Execution

Let us follow a single run from the tick of the clock to the record left behind in history.

1

The watch is stored and registered

When you save a watch, it is written to the watches index. The node holding the relevant shard registers its schedule with the trigger engine. If the watch is inactive, no schedule is registered.

2

The trigger fires

At the scheduled moment, the trigger engine creates a triggered event, recording both the scheduled time and the actual triggered time.

3

The run is queued

A record of the pending run is written to the triggered watches index, and the run enters the execution queue. If the same watch is already queued, the new run may be skipped, and this is noted.

4

The input is executed

A worker thread picks up the run and executes the input, for example a search. The result becomes the payload.

5

The condition is evaluated

If the condition is false, the run stops and is recorded as not needing action. If true, the run continues.

6

Throttle and acknowledgement are checked

For each action, Watcher checks whether it is throttled or already acknowledged. Actions that must be held back are skipped and marked as such.

7

Transforms and actions execute

Any transforms reshape the payload. Each remaining action then runs: templates are filled in and messages are sent.

8

The result is recorded

A watch record is written to the history indices, and the watch status in the watches index is updated so the next run knows what happened. The pending entry is removed.

sequenceDiagram
  participant Clock as Trigger engine
  participant Exec as Execution service
  participant Data as Data indices
  participant Chan as Notification channel
  participant Hist as History index
  Clock->>Exec: Trigger fired for watch
  Exec->>Data: Run input search
  Data-->>Exec: Search result
  Exec->>Exec: Evaluate condition
  Exec->>Chan: Send action if condition true
  Exec->>Hist: Write watch record
        
FIG 5 — The conversation between Watcher components during one run

Recovery after a failure

The triggered watches index exists for a good reason. If a node stops in the middle of a run, the pending entry is still there. When Watcher starts again on that shard, it can find these orphaned entries and run them, so an alert that was interrupted by a restart is not simply forgotten. This recovery is best-effort: very old pending entries may be handled differently than fresh ones, so do not treat it as a promise of exactly-once delivery.

At-least-once thinking

Alerting systems are usually designed so that they would rather send an alert twice than not at all. In practice this means occasional duplicates after failures are possible, and receiving systems should tolerate them. Paging services help with this by merging repeated alerts that carry the same key into one incident.

i
Insight

Every step in the run can fail on its own: the search may time out, the condition may hit an unexpected value, the mail server may refuse the connection. Watcher records where in the chain a failure happened, which makes the history invaluable when you debug.

11Throttling and Acknowledgement: Keeping Alerts Quiet

If a problem lasts an hour and the watch runs every minute, it could send sixty identical messages. Two tools prevent that.

Throttling

Throttling sets a minimum gap between two executions of the same action. If an email action has a throttle period of thirty minutes, then after it sends one message, Watcher will skip it for the next thirty minutes even if the condition stays true. The watch keeps running, and the condition keeps being checked, but that action stays silent until the period ends. A throttle can be set on the whole watch or on each action separately, so a chat message can repeat every ten minutes while a page repeats only every hour.

Simple Analogy

A car horn that beeps continuously while you are stuck in traffic would drive everyone mad. A polite driver beeps once, then waits. Throttling is the waiting period between beeps.

Acknowledgement

Throttling works on time. Acknowledgement works on human attention. When a person knows about an alert and is dealing with it, they can acknowledge it. Watcher then stops sending that action while the condition stays true. Once the condition becomes false, the acknowledgement resets automatically, so the next real problem will notify again. This matches how people actually work: “I know, I am on it, be quiet until it is fixed, and then tell me if it comes back.”

Action states

StateMeaning
Awaits successful executionThe action has not yet run successfully since the condition last became true
AckableThe action has run and can now be acknowledged
AcknowledgedA person has silenced it until the condition clears
ThrottledThe action was skipped because the throttle period had not ended
stateDiagram-v2
  [*] --> AwaitsExecution
  AwaitsExecution --> Ackable: action runs successfully
  Ackable --> Acknowledged: person acknowledges
  Acknowledged --> AwaitsExecution: condition becomes false
  Ackable --> AwaitsExecution: condition becomes false
        
FIG 6 — A simplified view of how an action moves through acknowledgement states

Choosing a strategy

Strategy

Short throttle for awareness

Chat messages that repeat every ten to thirty minutes keep the team aware without spamming.

Strategy

Long throttle for paging

Pages repeat rarely, because the responder already knows. Let the paging service handle escalation.

Strategy

Acknowledge during response

Encourage responders to acknowledge so that the system respects the fact that a person is now involved.

Strategy

Recovery messages

Add a separate watch or action that says “the problem is over”, so people know when to relax.

!
Common Misconception

Throttling does not stop the watch from running. It only holds back the actions. The search still runs every time, so a throttled watch still costs cluster resources. If a watch is no longer needed, deactivate it instead of just throttling it.

12Building and Testing Watches Safely

An untested alert is a gamble. Watcher gives you several ways to try a watch before it ever wakes someone at night.

The execute tool

The execute watch API runs a watch on demand. You can run a stored watch by name, or supply a complete definition that is not stored at all, which is ideal for experiments. You can also override parts of the run. For example, you can ignore the condition to force the actions to run, or supply your own trigger time to see how the search window behaves for a moment in the past.

Action modes

Mode

Simulate

Builds the message and shows it to you but does not send it. The safest way to check a template.

Mode

Force simulate

Like simulate, but ignores throttling and acknowledgement so you can see the message even if it would normally be held back.

Mode

Execute

Really sends the message, but respects throttle and acknowledgement rules.

Mode

Force execute

Really sends the message and ignores the throttle. Use with great care.

Mode

Skip

Does not run the action at all, so you can test the earlier parts of the watch in isolation.

A safe workflow

1

Prove the search first

Run the same search in Kibana or with the search API and confirm that it returns what you expect, over a realistic period.

2

Test the condition with real data

Run the execute tool with actions skipped. Check that the condition is true when it should be and false when it should not.

3

Simulate the messages

Use simulate mode to read the exact message text, and check every link, number, and label.

4

Send a real message to a test channel

Point the action to a private test channel or mailbox and confirm delivery and formatting.

5

Deploy, watch the history, and tune

Switch to the real destination and observe the first days of history. Adjust thresholds and throttles based on what you see.

i
Practical Tip

Keep a small collection of test scenarios, such as “quiet hour”, “small spike”, and “outage”, and replay them whenever you change a watch. Alerting logic breaks quietly, and a regular replay catches regressions before real incidents do.

Recording test runs

By default, a manual execution is not saved into the history unless you ask for it. You can choose to record it. Recording is helpful when you are debugging and want to keep a trace, but it also pollutes the history with test entries, so use it deliberately.

13Alert Design Patterns That Work

Over the years, teams have converged on a handful of reliable alert shapes. Here are the most useful.

Pattern 1: The error-rate threshold

Count errors over a short window and compare to a limit, ideally as a percentage of total requests rather than a raw number. A percentage stays meaningful when traffic doubles at peak hours. Add a minimum request count so a quiet night with two requests and one error does not produce a false alarm.

Pattern 2: The dead-man’s switch

Alert when data stops arriving. A watch counts documents from a service in the last few minutes, and fires when the count is zero. This catches the most dangerous failure of all: the silent one, where the very system that would report the problem has stopped working.

Pattern 3: The comparison with the past

Compare the current window with the same window a day or a week earlier, and alert on a large relative change. This copes with daily and weekly rhythms without needing a different threshold for every hour.

Pattern 4: The sustained condition

Alert only when a bad state persists across several consecutive checks, by looking at a longer window with multiple buckets and requiring that all or most of them are bad. This filters out brief spikes that fix themselves.

Pattern 5: The tiered escalation

Use several actions with different conditions in one watch: a chat note for mild trouble, a ticket for a lasting issue, and a page for severe impact. People get the level of interruption that matches the level of risk.

Pattern 6: The scheduled report

Use an always-true condition with a daily or weekly trigger to send a summary: yesterday’s totals, the slowest pages, and any incidents. This is not an alert, but it uses the same machinery and builds a healthy habit of reviewing the data.

Pattern 7: The alert audit trail

Add an index action to every important watch so each alert becomes a document in an alerts index. You can then chart how often each alert fires, which ones are noisy, and how quickly they clear, and improve your alerting with real evidence.

flowchart TD
  W[One watch runs each minute] --> C[Count errors and total requests]
  C --> D{Error rate high and enough traffic?}
  D -->|No| Q[Quiet]
  D -->|Yes| L1[Chat message to team]
  D -->|Very high| L2[Page the on-call engineer]
  D -->|Yes| L3[Write alert record to index]
        
FIG 7 — One watch feeding several actions at different severity levels
“Alert on symptoms people feel, and investigate causes with dashboards.”

Symptoms versus causes

A good rule is to page people on symptoms that affect users, such as failing checkouts or slow searches, and to leave causes, such as high processor use on a single server, for dashboards and low-priority notifications. A busy processor may be perfectly healthy. A failing checkout never is.

14Security and Compliance

A watch can read data and call outside systems. That power needs guard rails.

Whose permissions does a watch use?

When a watch is saved through the API or Kibana, Elasticsearch records the security context of the user who saved it. When the watch later runs on its own, it uses those recorded permissions to run its searches. This means a watch can only read the indices the author was allowed to read at that time. It also means that if the author’s roles change afterward, the watch may keep the older permissions until it is saved again, and if the author’s account is removed, the watch may start failing. Treat the ownership of watches like the ownership of any automated job: give important watches to a dedicated service account, not to a person who may leave the company.

Roles for Watcher

Role

Watcher admin

Can create, edit, delete, activate, and acknowledge watches and view history. For the platform team.

Role

Watcher user

Can view watches and history but not change them. For people who need to look but not touch.

Privilege

Manage and monitor privileges

Cluster privileges that let you build custom roles, such as a team that manages only its own alerting.

Data access

Index privileges

The author needs read access to the data indices and write access to any index an action writes to.

Protecting secrets

Alert channels need credentials: mail server passwords, chat webhook addresses, paging keys, and passwords for web inputs. Keep these in the secure settings store on each node, and refer to accounts by name in watches. If a watch must include a secret inside its own definition, Watcher can encrypt sensitive values when a system key is configured, and it hides them when the watch is read back. Never put a secret in a message template, because messages are stored in history and delivered to third parties.

Outbound calls and network safety

Webhook actions and HTTP inputs make requests from inside your network. Restrict which addresses they may call using the allowed-hosts settings, so a mistake or a malicious edit cannot turn Watcher into a way to probe internal systems. Use encrypted connections for all outbound calls and verify certificates.

What alerts reveal

Alert messages travel through email servers, chat platforms, and paging systems that may be operated by other organizations. Avoid including personal data, secrets, or full log lines with sensitive content in the message. A short description with a link to a secured dashboard is usually safer than pasting raw data.

!
Least Privilege

The account that owns a watch should be able to read only the indices that the watch needs. If it can read everything, a copy-paste mistake can send confidential data to a channel where it does not belong.

Audit and change control

Alert definitions are part of your operational safety, so changes to them deserve the same discipline as code. Keep watch definitions in a repository, review changes, and deploy through automation. Elasticsearch audit logging, where available under your subscription, can record who created, changed, or deleted a watch.

15Performance and Capacity Planning

Watches are cheap one at a time and expensive in bulk. Planning keeps alerting from becoming a load problem.

What each watch costs

The cost of a watch is mostly the cost of its input search, multiplied by how often it runs. A simple count over a small window on a well-indexed field is very cheap. A wide aggregation across a month of data every minute is expensive. Add the cost of actions, which are usually small unless they call slow external services, and the cost of writing the history record.

Multiply it out: a hundred watches running every minute is a hundred and forty-four thousand searches per day. That is manageable when each is light, and a serious burden when each is heavy.

Runs
Frequency multiplied by number of watches
Weight
Cost of each search and its time window
History
One record written per execution

Ways to make watches lighter

Tip

Shorten the window

Look only as far back as the decision needs. Five minutes is often enough, and cheaper than an hour.

Tip

Filter, do not scan

Use filters on indexed fields and time ranges, and avoid expensive text searches inside the loop.

Tip

Ask for counts, not documents

Set the returned hits to none when only totals or aggregations matter.

Tip

Target specific indices

Name the exact data streams or index patterns rather than searching everything.

Tip

Share one search across actions

One watch with tiered actions is cheaper than three watches that repeat the same search.

Tip

Stagger schedules

Avoid having hundreds of watches all fire on the same second of the minute. Spread offsets so load is smooth.

Watch history growth

Every execution writes a record, and records for busy watches accumulate quickly. Watcher stores history in time-based indices, and recent versions manage their retention with an index lifecycle policy. Confirm that the policy exists and matches how long you actually want to keep history, and reduce the amount of data stored by keeping the payload small. A history full of huge search responses is expensive to store and to search.

Cluster health and Watcher

Watcher depends on a healthy cluster: the watches index must be available, and searches must complete. During a serious incident, such as a cluster running out of memory, Watcher can be one of the first casualties, at the very moment you need it. This is why many organizations run alerts about the health of their production cluster from a separate monitoring cluster.

flowchart LR
  P[Production cluster] -->|metrics and logs| M[Separate monitoring cluster]
  M --> W[Watcher on monitoring cluster]
  W --> N[Notifications to team]
        
FIG 8 — Watching the watcher: alerting on production health from a separate cluster

16Monitoring Watcher Itself

An alerting system that fails silently is worse than none, because it gives false comfort. So you must watch the watcher.

The stats API

The Watcher stats API reports the state of the service on each node: whether it is started, how many watches are currently loaded, how many executions are running or queued, and details of the queue. A growing queue means watches are arriving faster than they can be executed. A service that has stopped means no alert will fire until it is started again.

The history

The watch history holds one record per execution. Searching it tells you which watches failed, which actions failed, how long each run took, and how often each condition was met. Useful questions to ask of the history are: which watches fail most often, which take the longest, which have never fired, and which fire constantly.

QuestionWhere to lookWhat a bad answer means
Is Watcher running?Service state from the stats and start or stop callsNo alerts will fire at all
Is the queue growing?Queued executions in statsOverload, slow searches, or too many watches
Which watches fail?History records with a failed stateBroken searches, permissions, or bad conditions
Which actions fail?Action results inside history recordsUnreachable mail, chat, or paging services
Which watches are noisy?Count of executions where the condition was metThresholds too tight or missing throttles
Which watches are silent?Watches that never met their condition in monthsPossibly correct, or possibly broken

Alerts about alerts

A meta-watch is a watch that searches the watch history for failures and sends a message when many appear. Combine this with a dead-man’s switch that fires if no execution records appear at all for some time, since that would mean Watcher is stopped or the cluster is unhealthy.

Review as a habit

Schedule a regular review, perhaps monthly. Look at each alert that fired, decide whether it was useful, and improve or retire it. An alert that fired thirty times and led to action zero times is a candidate for removal or redesign. Good alerting is not built once. It is tended.

i
A Useful Habit

For every alert, record in its metadata the owner, the severity, and a link to the runbook. During reviews you can then search for alerts that lack any of these and fix the gaps.

17Watcher Compared With Kibana Alerting and Other Tools

Watcher is not the only way to alert on Elasticsearch data. Choosing well starts with knowing the neighbors.

Watcher and Kibana alerting

Kibana has its own alerting framework built around rules and connectors. A rule checks a condition on a schedule and runs actions through connectors to email, chat, and other services. Rules are created through a friendly interface, come with ready-made rule types for common needs, integrate with Kibana features such as observability, security, and machine learning, and have their own management and history views. Elastic’s own applications have moved toward this framework for their built-in alerts, and it is often the recommended starting point for new alerting work.

Watcher remains supported and is still valuable. Its strengths are its low-level flexibility, its direct API, its ability to express custom multi-step logic with chained inputs and transforms, and the large number of existing setups that already rely on it. Because feature sets and recommendations change between versions, check the current documentation to see which is favored for your case.

AspectWatcherKibana alerting
Where it livesInside ElasticsearchInside Kibana, storing its data in Elasticsearch
How you define alertsJSON watch definitions, with a basic user interface for simple casesGuided forms for rule types, plus APIs
FlexibilityVery high: chained inputs, scripts, custom transformsHigh for supported rule types, less free-form
Built-in alert templatesFew, mostly examplesMany, for observability, security, and more
Notification channelsEmail, chat, paging, ticketing, web, index, logA broader and growing connector list
Alert state and groupingThrottle and acknowledgement per actionAlert grouping, recovery actions, and snooze features
Depends on KibanaNoYes
Best fitCustom, API-driven, or existing Watcher estatesMost new, interface-driven alerting

Other approaches

Option

Machine learning anomaly detection

Learns normal behavior and flags unusual values without fixed thresholds. Its results can feed alerts through Kibana rules or watches.

Option

External monitoring platforms

Dedicated systems for metrics, on-call schedules, and incident handling. Watcher can send them events.

Option

Custom scripts and jobs

Flexible, but you must build scheduling, recovery, history, and security yourself.

Option

Stream processing

Reacts the instant an event arrives. Better for per-event reactions than for windowed checks.

i
Choosing

Neither choice is a trap. Many organizations use Kibana rules for the everyday alerts that teams manage themselves, and Watcher for a smaller set of highly customized alerts owned by a platform team. The important thing is to pick a home for each alert and keep an inventory.

18Advantages, Disadvantages, and Trade-offs

An honest look at what you gain and what you accept.

Advantages

  • Lives inside Elasticsearch, so there is no extra scheduler or service to run.
  • Any search or aggregation can drive an alert, over any index the author may read.
  • Distributed by design, with schedules spread across nodes and recovery after failures.
  • Built-in throttling and acknowledgement reduce noise.
  • Full execution history makes auditing and debugging possible.
  • Rich testing tools let you simulate before you send.
  • Flexible inputs, transforms, and multiple actions support unusual logic.

Disadvantages / Trade-offs

  • Requires a paid subscription or trial.
  • Watch definitions are raw JSON, which is harder to read and review than guided forms.
  • Shares resources with your data nodes, so heavy alerting competes with search and indexing.
  • Depends on the health of the cluster it watches unless you separate them.
  • Polling on a schedule, so it cannot react instantly and can miss events shorter than its interval.
  • Limited retry behavior for failed notifications.
  • Less integrated with newer Kibana features than Kibana alerting.

The trade-off in one sentence

Watcher gives you power and proximity to your data in exchange for care: you must design carefully, test thoroughly, and watch its own health, because the flexibility that makes it useful also makes it possible to build noisy, heavy, or fragile alerts.

“Power without discipline gives you a system that alerts on everything and helps with nothing.”

When Watcher is a strong fit

  • You need custom, multi-step alert logic that guided rule types cannot express.
  • You manage alerts as code through APIs and automation.
  • You already have a working Watcher estate and no strong reason to migrate.
  • Your alerts are based on windowed searches and aggregations of data you already keep in Elasticsearch.

When to consider something else

  • You need sub-second reactions to single events.
  • You want non-technical teams to build and manage their own alerts through a guided interface.
  • You need full on-call scheduling, escalation policies, and incident tracking in one place.
  • You want the data-source to be something other than Elasticsearch.

19Anti-Patterns and Common Mistakes

These mistakes appear again and again in real alerting systems. Each is easy to avoid once you can name it.

ANTI-PATTERN-01 Avoid
Problem

Hundreds of watches are set to run every few seconds, each with a wide search over days of data.

Why It’s Harmful

The alerting workload itself overloads the cluster, slowing the searches of real users and queuing or rejecting the very watches that matter.

Correct Approach

Match the interval to the speed of response. Keep windows short, searches light, and stagger the schedules.

ANTI-PATTERN-02 Avoid
Problem

An alert has no throttle and no acknowledgement, and sends a message on every run while a problem lasts.

Why It’s Harmful

Channels fill with duplicates, people mute them, and the next real incident is lost in the noise.

Correct Approach

Set throttles that fit the urgency, encourage acknowledgement, and add a recovery message so people know when the trouble is over.

ANTI-PATTERN-03 Avoid
Problem

Alerts are built on raw counts with fixed thresholds, ignoring traffic patterns and quiet periods.

Why It’s Harmful

They fire constantly at peak hours and never at night, or fire falsely when traffic is tiny and one error looks like a crisis.

Correct Approach

Use rates instead of counts, require a minimum volume, compare with past periods, and check for sustained conditions.

ANTI-PATTERN-04 Avoid
Problem

Important watches are created under a personal account, and the person later changes teams or leaves.

Why It’s Harmful

When the account is removed or its permissions change, watches may fail silently, and nobody remembers how they work.

Correct Approach

Create critical watches under a dedicated service identity with minimal permissions, store definitions in version control, and record an owner in the metadata.

ANTI-PATTERN-05 Avoid
Problem

Passwords, keys, and webhook addresses are pasted directly into watch definitions and message text.

Why It’s Harmful

Secrets end up in history, exports, and screenshots, and are hard to rotate.

Correct Approach

Store secrets in the secure settings on each node and reference named accounts. Keep messages free of sensitive data.

ANTI-PATTERN-06 Avoid
Problem

The only place alerting for the production cluster runs is the production cluster itself, and nobody monitors Watcher’s own health.

Why It’s Harmful

When the cluster is in trouble, alerting fails with it, and a stopped Watcher service produces nothing but silence that looks like health.

Correct Approach

Alert on cluster health from a separate monitoring cluster, add a dead-man’s switch, and watch the stats and history.

ANTI-PATTERN-07 Avoid
Problem

An alert says “Error detected” with no numbers, no link, no owner, and no advice.

Why It’s Harmful

The receiver must start from zero every time, response is slow, and the alert soon gets ignored.

Correct Approach

Write messages as small stories: what, how bad, since when, where to look, and who owns it, with a link to a runbook.

Smaller mistakes worth avoiding

  • Alerting on every metric: each alert should map to an action a person can take.
  • Never reviewing alerts: stale thresholds drift away from reality.
  • Forgetting about time zones: report schedules that surprise the people who read them.
  • Deleting a watch to silence it: deactivate it instead, so you can bring it back and keep its history.
  • Skipping tests after edits: small changes to a condition can invert its meaning.

20Real-World and Industry Examples

These are common, representative uses. They describe patterns seen across industries, not accounts of any named company.

Online retail and payments

A shop watches the rate of failed payments, the delay of the checkout page, and the number of orders per minute. If orders drop sharply compared with the same time last week, a watch pages the on-call engineer, because lost sales are the most direct cost of any outage. A daily report sends the previous day’s totals to the business team.

Security operations

Analysts alert on patterns such as many failed logins from one address followed by a success, a new administrator account created outside working hours, or a burst of data leaving the network. Elastic Security has its own detection rules, but teams sometimes add watches for special cases built from custom data sources.

Platform and infrastructure operations

Operations teams alert on disks filling up, services that stop sending logs, certificates about to expire, and jobs that did not finish on time. The dead-man’s switch pattern is especially common here, because silence often means something crashed.

Financial services and compliance

Banks and insurers use scheduled watches to check that end-of-day batch jobs completed, that reconciliation totals match, and that unusual transaction volumes are flagged for review. Index actions record each alert as an auditable document.

Manufacturing and sensor data

Factories store sensor readings in Elasticsearch. Watches look for temperatures or vibrations outside safe ranges for several consecutive readings, and create maintenance tickets so machines are serviced before they fail.

Search and content platforms

Teams running their own search services watch for slow query times, a rising share of searches with no results, and indexing lag. These alerts protect user experience and reveal problems in the data pipeline early.

flowchart TD
  A[Orders per minute drop against last week] --> B[Watch condition is true]
  B --> C[Chat message to shop team]
  B --> D[Page to on-call engineer]
  B --> E[Alert stored in alerts index]
  D --> F[Engineer opens runbook and dashboard]
        
FIG 9 — A typical retail alert reaching several destinations at once

21A Worked Example: Alerting for an Online Checkout

Let us design alerting for a made-up online shop, step by step. All numbers are illustrative.

The situation

The shop logs every checkout attempt into Elasticsearch. Each document records the time, the result (success or failure), the payment provider, the response time, and the server. On a normal weekday, there are between two hundred and two thousand attempts per five minutes, depending on the hour. Failures normally stay below two percent.

Step 1: Decide what matters to customers

Customers care that checkout works and is fast. So we choose three symptoms: the failure rate, the slowness of the checkout, and the absence of any checkout activity. Everything else, such as server processor load, will live on dashboards and not wake anyone up.

Step 2: Design each watch

WatchScheduleWhat it asksConditionActions
Checkout failure rateEvery minuteFailures and total attempts in the last five minutes, by providerRate above five percent and at least fifty attemptsChat message; page if above fifteen percent
Checkout slownessEvery two minutesThe ninety-fifth percentile response time in the last ten minutesAbove four seconds for both of the last two checksChat message and ticket
No checkoutsEvery minuteCount of attempts in the last ten minutesZero, only during opening hoursPage immediately
Traffic dropEvery ten minutesAttempts now against the same hour last weekDown by more than halfChat message to the business team
Daily summaryEvery morningYesterday’s totals, failures, and slowest hoursAlwaysEmail to managers

Step 3: Write good messages

The failure-rate message says, for example: “Checkout failure rate is 11 percent (limit 5 percent) over the last 5 minutes, mostly through payment provider B. Started around 14:05. Dashboard and runbook links below.” The reader sees impact, size, cause hint, timing, and next step in one glance.

Step 4: Control noise

The chat action repeats at most every fifteen minutes, and the page repeats at most every hour. Responders acknowledge the alert as soon as they start work. A separate small watch sends “checkout failures are back to normal” when the rate drops below the limit, so the team knows they can stand down.

Step 5: Test and roll out

1

Replay last month’s worst outage

Run the watches against the outage window with the trigger time overridden, and check that they would have fired early enough and only once.

2

Replay a normal busy day

Confirm that no watch would have fired falsely during peak traffic or the quiet hours.

3

Send to a test channel for a week

Observe the messages in a private channel and refine wording and thresholds.

4

Go live and review after a month

Check the history and the alerts index, and remove or tune anything that was noisy or never useful.

i
Lesson

Notice that most of the effort went into choosing what to measure, avoiding false alarms, and writing messages that help. Only a small part of the work was the mechanics of the watch itself.

22Troubleshooting Scenarios

Symptoms rarely announce their cause. These scenarios link common symptoms to likely explanations.

Scenario 1: A watch never fires, although the problem is clearly happening

Check that the watch is active and that the Watcher service is started. Execute the watch manually with the condition not ignored and read the result: does the search return what you expect? Common causes are a wrong index pattern, a time window that does not overlap the data, a field name that differs from the documents, or the author’s permissions no longer covering the index.

Scenario 2: The condition is true but no message arrives

Look at the action result in the history. The action may have been throttled or acknowledged, or it may have failed because the mail server, chat address, or paging key is wrong or unreachable. Check that the notification account is configured on every node that may run the watch.

Scenario 3: Alerts arrive late

Compare the scheduled time with the triggered time in the history. A large gap points to a queue backlog from overload. Also check how long each search takes, and whether the interval is shorter than the run time. Reduce the workload or spread out the schedules.

Scenario 4: The same alert floods the channel

Add or lengthen the throttle, and encourage acknowledgement. If the condition flickers between true and false, the acknowledgement keeps resetting, so require the problem to last several checks before alerting.

Scenario 5: Watches began failing after an account change

The permissions recorded when the watch was saved may no longer be valid. Save the watch again under a suitable account, ideally a dedicated service identity, and confirm it can read the necessary indices.

Scenario 6: Watches stopped after a cluster restart or maintenance

Check the service state in the stats. If Watcher was stopped for maintenance, start it again, and add a dead-man’s switch so a long silence gets noticed in future.

Scenario 7: Times in reports are wrong

Review the time zone used by the schedule and by the messages. Format times explicitly in the template, and state the zone in the message text.

23An Adoption Roadmap and Best Practices

If you are introducing Watcher to a team, a staged approach reduces risk and builds trust in the alerts.

1

List what must never go unnoticed

Interview the teams that run and use the system. Write down the few failures that hurt most, and how quickly each must be noticed.

2

Confirm licensing and decide on tooling

Check that your subscription covers Watcher, and decide which alerts belong in Watcher and which in Kibana rules.

3

Configure channels securely

Set up email, chat, and paging accounts in the secure settings, restrict outbound hosts, and test each channel.

4

Start with a few high-value watches

Build the failure-rate, silence, and slowness alerts for your most important service. Test them thoroughly.

5

Add watches that watch the watchers

Monitor Watcher’s state, queue, and failures, and set up a separate cluster for production health alerts.

6

Put definitions under version control

Deploy changes through review and automation, and record owner, severity, and runbook in metadata.

7

Review monthly and prune

Use the alerts index and history to find noisy or useless alerts, and improve them.

AreaBest practice
DesignAlert on user-visible symptoms, use rates and minimum volumes, and compare with past periods where patterns repeat.
ScheduleChoose intervals from the required response speed. Stagger schedules and keep windows short.
SearchesReturn counts and aggregations rather than documents. Filter on indexed fields and target specific indices.
MessagesLead with impact, include numbers, time, links, and owner. Keep sensitive data out.
Noise controlUse throttles, acknowledgement, sustained conditions, and recovery messages.
SecurityUse dedicated service accounts, least privilege, secure settings for secrets, and restricted outbound hosts.
OperationsMonitor Watcher stats and history. Add a dead-man’s switch. Alert on production health from a separate cluster.
Change controlKeep definitions in version control, review changes, and replay test scenarios after edits.
GovernanceRecord owner, severity, and runbook for every alert. Review and retire alerts regularly.

24Deep Dive: Templating and Context Variables

Templates are what turn a generic watch into a specific, helpful message. Understanding what data they can see is the key.

The execution context

During every run, Watcher builds a bundle of information called the context. Templates and scripts can read from it. The context carries the identity of the watch, the time the run was scheduled, the time it actually started, the metadata you attached to the watch, and the payload produced by the input and transforms. Nearly every useful message is just a few well-chosen values pulled from this bundle.

Context

Watch identity

The name of the watch, useful for telling readers which alert they are looking at and for linking to its definition.

Context

Trigger times

The scheduled time and the actual triggered time, used both in messages and in the search window.

Context

Execution time

The moment the run began, helpful for telling readers when a problem was noticed.

Context

Metadata

Your own labels, such as owner, severity, dashboard link, and threshold, so that messages and conditions share one source of truth.

Context

Payload

The data from the input and transforms: counts, aggregation buckets, and example documents.

Context

Action results

Results of earlier steps that later steps or history records can refer to.

Why metadata is a quiet hero

Imagine that the threshold appears three times in a watch: once in the search, once in the condition, and once in the message. If you change one and forget the others, the alert says “limit is five percent” while the condition uses ten. Placing the threshold in the metadata, and reading it in all three places, means there is one number to change. The same goes for the dashboard link and the owner name.

Formatting values for humans

Raw values are often ugly: long decimals, timestamps in machine format, and huge counts without separators. Templates can loop over lists, show or hide sections depending on whether a value exists, and format numbers and dates through simple helper functions. A message that lists the top three affected servers, with a friendly time and a rounded percentage, is far easier to read than a dump of raw fields.

Simple Analogy

A good news reporter does not read the raw police report aloud. They pick the important facts, put them in a sensible order, and use plain language. Templates are the reporter’s editing desk: they decide which facts from the raw payload appear in the story, and how.

Escaping and safety

Values from your data may contain characters that mean something to the destination, such as angle brackets in email or quotation marks in a web request body. A log line that happens to include those characters can break formatting or, worse, be interpreted as markup. Keep message templates simple, and be careful with any field that contains text written by outsiders, such as user input or web addresses in log lines.

!
Watch Out

Never assume a value exists. If a search returns no buckets, a template that reaches into the first bucket may fail and the whole action may be recorded as failed. Design templates to cope with empty results, for example by showing a friendly fallback line.

25Scaling, High Availability, and Multi-Team Use

As more teams rely on alerting, the way you organize and scale Watcher matters as much as any single watch.

Scaling out

Watcher scales mostly by adding nodes and by keeping each watch light. Because the schedules and executions are spread across the nodes that hold shard copies of the watches index, adding capable data nodes helps to spread the work. But if every watch is heavy, adding nodes only moves the pain around. The first lever is always to make searches cheaper, and the second is to add capacity.

High availability

The watches index keeps copies on several nodes, so the loss of a single node does not lose the definitions of your alerts. Another node can take over the schedules. For the strongest guarantees, keep your cluster spread across zones, keep at least the recommended number of master-eligible nodes, and make sure notification accounts are configured on every node that could run a watch, not just some of them.

flowchart TD
  subgraph Z1[Zone A]
    A1[Data node with watches shard]
  end
  subgraph Z2[Zone B]
    B1[Data node with watches copy]
  end
  subgraph Z3[Zone C]
    C1[Data node with watches copy]
  end
  A1 -.->|fails| B1
  B1 --> N[Notifications continue]
        
FIG 10 — Copies of the watches index across zones let another node take over if one fails

Many teams, one cluster

When several teams create watches in the same cluster, problems of ownership and fairness appear. One team’s heavy watch can slow everyone else’s. One team’s mistake can flood a shared channel. Agree on conventions before the estate grows.

ConcernSuggested convention
NamingPrefix each watch with the team and service, such as team, service, and symptom
OwnershipRecord owner, severity, and runbook in the metadata of every watch
Fair useSet guidelines for the shortest interval, the longest window, and the maximum searches per watch
DestinationsEach team routes to its own channels, and only platform staff manage shared or paging destinations
Change processAll changes go through review and automated deployment from version control
ReviewA monthly look at noisy, silent, and failing watches with each owner

Multiple environments

Keep separate copies of alerts for development, testing, and production. Parameterize the destinations and thresholds through metadata or deployment settings, so the same watch definition can be promoted through the environments with only the values changed. This avoids the classic mistake of a test alert paging a real person at night.

26Measuring the Quality of Your Alerting

You cannot improve what you do not measure. A few simple numbers reveal whether your alerts are helping.

Measure

Precision

Of all the alerts that fired, how many pointed to a real problem that needed action? Low precision means noise.

Measure

Recall

Of all the real incidents, how many were caught by an alert before customers noticed? Low recall means blind spots.

Measure

Time to detect

How long between the start of the problem and the first alert. Shorter is better, within reason.

Measure

Time to acknowledge

How long until a person responded. It reflects both the clarity of the message and the health of your on-call process.

Measure

Alerts per person per week

A simple load measure. Too many, and people burn out. Too few may mean that important things are not covered.

Measure

Repeat rate

How often the same alert fires again shortly after being resolved, which often signals a fix that did not last or a threshold that flickers.

Using the alerts index

If every important watch also writes a record into an alerts index, you can build a dashboard about your alerting. Chart alerts per day, per team, and per watch. Show which alerts were acknowledged, how long they took to clear, and which were never acted upon. This turns discussions about alert fatigue from opinion into evidence.

1

Collect after every incident

For each real incident, note which alert caught it first, how long it took, and whether earlier warning was possible.

2

Review the noisiest alerts each month

Sort by count and by fraction ignored. Adjust thresholds, add sustained conditions, or retire them.

3

Close the gaps

Where an incident had no alert, or a late one, write a new watch or tighten an existing one, and test it by replaying the incident.

4

Share the results

Show the team the trends. When people see the numbers improve, they trust the alerts more and respond faster.

“The best alert is the one you rarely see and always act on.”

27Migrating and Coexisting With Kibana Alerting

Many teams find themselves with older watches and newer rules at the same time. A calm plan avoids gaps.

Take an inventory first

List every existing watch: what it checks, how often, where it sends messages, who owns it, and how often it fires. You will usually discover that some watches are obsolete, some duplicate others, and a small number are truly critical. Only the critical and useful ones deserve migration effort.

Decide alert by alert

Watch typeSuggested destinationReason
Simple threshold on a single indexKibana ruleGuided forms and shared connectors make it easy to maintain
Standard observability or security checkBuilt-in rule typeReady-made logic saves effort and receives updates
Multi-step chained logicKeep in WatcherChained inputs and transforms are hard to reproduce
Alerts deployed by existing automationKeep, or migrate with automationAvoid rework unless there is a clear benefit
Obsolete or never firesRetireLess to maintain and monitor

Run in parallel

When you migrate an alert, run the old and the new versions side by side for a while, with the new one sending to a test destination. Compare when each fires. When the new alert matches or improves on the old one, switch its destination to the real one and deactivate the old watch. Keep the old definition for a while so you can revert.

Avoid double notification

During the overlap, make sure the same problem does not page the same person twice. Only one version should use the real paging destination at a time.

i
Do Not Rush

There is no prize for migrating quickly. Watcher continues to work, and a slow, checked migration protects you from the worst outcome of all: an alert that people believed existed but silently stopped working.

28The Human Side: Runbooks, On-Call, and Culture

Technology sends the message. People decide what happens next. Alerting works only when the human process around it works too.

Every alert deserves a runbook

A runbook is a short page that answers the question a tired person asks at three in the morning: “What do I do now?” It explains what the alert means, how to confirm it is real, the first three things to check, how to fix the common causes, and who to call if those fail. Link the runbook from the alert message itself, so there is no searching. If you cannot write a runbook for an alert, that is a sign the alert may not be actionable, and it may not deserve to interrupt anyone.

Simple Analogy

A fire alarm is far more useful in a building where the exits are marked and people have practiced the drill. The alarm tells you something is wrong. The marked exits and the practiced drill tell you what to do. A runbook is the marked exit for your alert.

Route alerts to owners

Messages should go to the team that can fix the problem, not to a giant shared channel that everybody has learned to ignore. Use metadata to hold the owner of each alert and build routing from it. Shared channels are fine for awareness, but the thing that wakes a person should have a clear owner and a clear rotation.

Protect the people who respond

Practice

Severity levels with meaning

Reserve the highest level for problems that need action right now, and send everything else to channels or tickets that can wait until morning.

Practice

Fix or remove noisy alerts

Treat any alert that wakes someone for no reason as a defect to be repaired, not as a fact of life.

Practice

Blameless reviews

After each incident, ask what the alerts did well and badly, without blaming people. Improve the system, not the guilt.

Practice

Share the load

Rotate on-call duty fairly and keep the number of pages per shift low enough to be sustainable.

Building trust in alerts

Trust is the real currency of alerting. When every alert that arrives is real and useful, people respond quickly and calmly. When many alerts are false, people start to hesitate, delay, or ignore them. Each false alarm spends a little of that trust, and it takes many good alerts to earn it back. Guard it by testing carefully, tuning steadily, and retiring alerts that do not help.

i
A Simple Test

For any alert, ask three questions. Would a person need to act on this within the hour? Do they know what to do? Is it usually real? If the answer to any is no, change the alert, change its destination, or remove it.

29Glossary of Terms

A quick reference for the vocabulary used throughout this guide.

Term

Watch

A stored alerting job made of a trigger, input, condition, optional transform, and actions.

Term

Trigger

The schedule that decides when a watch runs.

Term

Input

The step that loads data, usually by running a search.

Term

Condition

The test that decides whether the actions should run.

Term

Transform

An optional step that reshapes the payload before actions use it.

Term

Action

What a watch does when its condition is true: send, call, write, or log.

Term

Payload

The working data passed from step to step during a run.

Term

Throttle

A minimum gap between two runs of the same action.

Term

Acknowledge

A person’s signal that an alert is known, which silences the action until the condition clears.

Term

Watch history

The time-based indices that record every execution and its outcome.

Term

Dead-man’s switch

An alert that fires when expected data stops arriving.

Term

Mustache template

The simple templating language used to fill values into messages and requests.

30Frequently Asked Questions

Q1Is Watcher the same as Kibana alerting?

No. Watcher is built into Elasticsearch and defines alerts as stored watches. Kibana alerting is a separate framework in Kibana, built on rules and connectors. They solve the same broad problem in different ways, and many organizations use both.

Q2Do I need a paid license to use Watcher?

Yes. Watcher is a subscription feature, not part of the free basic license, though a trial can be used to try it. Licensing details can change, so check the documentation for your version.

Q3How often can a watch run?

Intervals can be very short, but that does not mean they should be. Choose an interval that matches how fast someone can respond, and make sure the watch finishes faster than the interval.

Q4Can a watch alert on missing data?

Yes. Count documents in a recent window and fire when the count is zero. This dead-man’s switch pattern is one of the most valuable alerts you can build.

Q5What is the difference between throttling and acknowledgement?

Throttling holds an action back for a set period of time, no matter what. Acknowledgement is a person’s request to be quiet until the condition clears. Both reduce repeated messages, in different ways.

Q6Does a throttled watch still cost resources?

Yes. The search and the condition still run every time. Only the actions are held back. Deactivate watches you no longer need.

Q7Which permissions does a watch run with?

It uses the permissions recorded from the user who saved it. If that user’s access changes or the account disappears, the watch may fail. Use dedicated service accounts for important watches.

Q8Can I test a watch without sending real messages?

Yes. The execute tool can run a watch on demand and simulate the actions, showing you the messages without sending them. You can also skip actions, ignore the condition, or supply a custom time.

Q9What happens if a node fails while a watch is running?

Pending runs are recorded in a system index, and another node holding a copy of the watches shard can take over the schedule and resume interrupted runs. Recovery is best effort, so occasional duplicates or delays are possible.

Q10Where can I see what a watch did?

In the watch history indices, which hold a record of each execution, including the input result, whether the condition was met, and the outcome of each action. Kibana also shows recent executions for each watch.

Q11Will Watcher retry a failed email or message?

Not indefinitely. Failures are recorded in the history, but a message may be lost if the destination is down at that moment. For critical alerts, use a paging service and monitor for failed actions.

Q12Can one watch send different messages to different people?

Yes. A watch can have several actions, each with its own condition, transform, throttle, and destination. This lets you send mild warnings to a chat channel and severe ones to a paging service.

Q13Should I alert on every metric I collect?

No. Alert on symptoms that affect users and that a person can act on. Keep the rest on dashboards, where they help investigation without demanding attention.

Q14How do I know Watcher itself is working?

Check the stats for the service state and queue, search the history for failures, and add a dead-man’s switch that fires if executions stop appearing. For production health, alert from a separate monitoring cluster.

31Summary and Key Takeaways

Watcher is Elasticsearch’s built-in alerting engine. A watch is a stored job that wakes on a schedule, loads data with a search or a web call, judges it with a condition, optionally reshapes it, and then sends messages, creates tickets, or records the result. It runs inside the cluster, spreads across nodes, keeps a full history, and offers throttling, acknowledgement, and testing tools. Its power is flexibility and closeness to your data. Its risks are noise, load, and silent failure, which careful design, sensible schedules, secure ownership, and monitoring of Watcher itself can address. Kibana alerting is a friendly alternative for many everyday needs, and the two can live side by side. Above all, a good alert is a small, clear story that reaches the right person at the right time and asks them to do something useful.

Key Takeaways

  • A watch is five building blocks — trigger, input, condition, optional transform, and actions, all stored as data and run inside Elasticsearch.
  • Schedule to match response speed — faster is not better, because every run costs a search and heavy alerting can overload the cluster.
  • Design for signal, not noise — use rates with minimum volumes, comparisons with the past, sustained conditions, throttles, and acknowledgement.
  • Write messages as small stories — impact, numbers, timing, next step, owner, and a link to a runbook.
  • Own watches with service identities — watches use the permissions recorded when they were saved, so avoid tying critical alerts to a person’s account.
  • Watch the watcher — monitor its state, queue, and history, add a dead-man’s switch, and alert on production health from a separate cluster.
  • Choose the right home for each alert — Watcher for custom, API-driven logic, and Kibana alerting for guided, everyday rules, and review both regularly.