Kibana: Actions, Frequency & Action Variables
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Checked on 2026-11-09 against Kibana 9.5.x. Tested with Elasticsearch 9.5.6 and Kibana 9.5.6 in the hands-on lab (trial licence): the rule with four actions below was created and fired, and its webhook delivery reached the receiver.
To do this by hand, follow Create a Rule with a Connector.
A rule that detects a problem and tells nobody is a dashboard with extra steps. In Kibana alerting, the action is the part that tells somebody, and it is also the part that decides whether the notification is useful or noise. An action says which connector to call (a Slack channel, a webhook, a PagerDuty service), when to call it (for which alert state, how often, only under which conditions) and what to send (a message built from variables). This page covers all four decisions. The rules that produce the alerts are on Rules & Stack Rule Types and Observability Rules; the connectors themselves are on Connectors; how long an alert lives and how to silence it is on Alert Lifecycle, Snooze & Maintenance Windows. The tool-neutral reasoning about who should be woken up and why is on Designing Actionable Alerts and Notifications & Incident Response; the Grafana equivalent of this page is the pair Notification Policies and Notification Templates. The two products divide the work differently: Grafana routes alerts centrally through a policy tree after the rule fires, whereas Kibana attaches the delivery decisions to each rule, so there is no central routing tree and every rule carries its own actions.
Source: Create and manage rules: Actions. The documentation files this under "Kibana Classic Alerting"; the newer Universal Alerting model is introduced on Universal Alerting & Watcher and has its own notification model.
Anatomy of an action
Every action in a Classic rule has the same five parts.
| Part | What it decides |
|---|---|
Connector |
The saved connector the action calls (its identifier is the |
Action group |
When the action runs, in terms of alert state ("query matched", "recovered", a severity). Required for per-alert actions. |
Frequency |
Whether the action covers each alert separately or a summary of all alerts, and how often it repeats. |
Conditions |
Optional extra gates: a KQL query on the alert, a time frame of days and hours. |
Params |
What is sent: the message, the webhook body, the severity, the incident fields. Every value is a Mustache template filled in from the action variables. |
Rules can have any number of actions, and they are independent: a rule can post a short line to chat the first time an alert fires, open a PagerDuty incident for the critical severity only, and write every state change to an index. In the UI the actions are added in the rule flyout of Stack Management > Rules (or the equivalent flyout of an Observability rule), in the section that follows the rule conditions.
Action groups: Run when
An alert is always in one action group, and each rule type defines its own list. The group decides which actions fire, and the special group recovered is how a rule says that an alert stopped matching. In the UI the choice is labelled Run when, and the options differ per rule type:
| Rule type | Run when (UI) | Notes |
|---|---|---|
Elasticsearch query |
Query matched, Recovered |
API group names are |
Custom threshold (Observability) |
Alert, Warning, No Data, Recovered |
The warning threshold is available from 9.5; the no-data choices from 9.4 on the Stack. See Observability Rules. |
SLO burn rate (Observability) |
Critical, High, Medium, Low, Recovered |
One group per burn rate window; define an action for every severity you want to hear about and one for recovery. See SLOs. |
Connectors behave differently per group. The documentation’s own example is Opsgenie: the action in the active group creates an
alert and the action in the recovered group closes it; PagerDuty works the same way, using a de-duplication key to correlate
trigger and resolve. A Slack action for the recovered group sends a "back to normal" message. If you add actions only for the
active group, nobody is ever told that the problem went away. In the API the group is the group field of the action; the
reference says to set it to default when the rule type needs no grouping of actions.
Sources: Create and manage rules: Actions (Run when), Custom threshold rule, SLO burn rate rule.
Per-alert actions and summary actions
The first frequency decision is whether the action describes one alert or all of them.
-
A per-alert action runs once for every alert that qualifies, and it needs an action group. Its message talks about one thing: this host, this service, this group. This is what you want for paging, where each incident has an owner.
-
A summary action runs once per interval for the whole rule and reports the alerts that were new, ongoing and recovered in that interval. It covers all alerts rather than one, so its message reads the alert collections. It suits chat channels and e-mail digests, where one line that says "3 new, 5 ongoing, 1 recovered" replaces nine messages.
In the API the difference is the summary flag of the action’s frequency object. A rule that groups its alerts, for example by
host.name, can generate dozens of alerts at once during an outage, so a summary action next to a per-alert action for only the
critical severity is a common arrangement: the channel gets the digest, the pager gets the critical few.
The action variables differ between the two kinds (see below): a summary action reads the alerts.* collections, a per-alert
action reads the alert.* and context.* values of its single alert.
Frequency: how often an action repeats
Kibana evaluates a rule at its check interval and an alert that stays active is still active at the next check. The frequency
tells Kibana whether to notify again. The three choices for a per-alert action, with the documentation’s labels and the
notify_when value of the API, are:
| UI label | API notify_when |
Behaviour |
|---|---|---|
On check intervals |
|
Runs when the alert becomes active and at every check while the conditions keep matching. Repeats every check interval, which is rarely what you want for chat or e-mail. |
On custom action intervals |
|
Runs when the alert becomes active and then again at the interval set in |
On status changes |
|
Runs once when the alert changes status (for instance from not-existing to active, or from one severity group to another) and not again while it stays in that group. Recovery is a status change. |
A summary action offers only the check interval or a custom interval, since a summary has no per-alert status change.
The documentation illustrates the effect with a rule that checks three servers every minute for CPU above 0.9. The same
scenario, written for the Bookshelf hosts web-01, web-02 and web-03 which cross the threshold one after the other, gives
this number of notifications per minute:
| Minute | On check intervals | Custom interval of 5 minutes | On status changes |
|---|---|---|---|
1: |
1 (web-01) |
1 (web-01) |
1 (web-01) |
2: |
2 (both) |
1 (web-02 only) |
1 (web-02 only) |
3: all three above |
3 (all) |
1 (web-03 only) |
1 (web-03 only) |
4 to 5: all three still above |
3 each minute |
0 |
0 |
6: still above |
3 |
1 ( |
0 |
The point of the table: on check intervals sent six notifications in the first three minutes, three of them about
web-01. A custom interval sends each alert once when it appears and repeats it every five minutes; a status change sends it
once. The practical rule is to use status changes for paging (the page opens an incident that stays open until recovery),
a custom interval for chat reminders of problems that are still open, and check intervals almost never. Alert summaries are the
other way to reduce volume. The figures for minutes 6 to 8 follow from the interval semantics above rather than from a
documented example, so confirm them in the lab.
A flapping alert is a special case: while an alert is flapping, actions configured to run on status changes do not run. The flapping settings are on Alert Lifecycle, Snooze & Maintenance Windows.
Source: Create and manage rules: Actions,
and for the API names the
Create a rule API reference
(frequency.notify_when, frequency.summary, frequency.throttle).
The API accepts notify_when and throttle on the rule itself as well, but the reference says you cannot set them at both
the rule level and the action level and recommends setting them for each action; editing a rule that carries rule-level values
converts them to action-level ones.
Conditional actions: only when it matters
Frequency decides how often; conditions decide whether. The rule flyout of Observability rules offers two extra gates under
the action frequency, and the rules API exposes them as alerts_filter:
-
If alert matches query: a KQL query that the alert must satisfy before the action runs. The query searches the alert documents, in the indices of the rule, so it can only use fields that exist on the alert (for a rule that groups by
host.name,host.name : "web-01"is valid; a field the rule never wrote is not). -
If alert is generated during timeframe: days of the week (1 is Monday, up to 7), a start and end in 24-hour notation and an ISO time zone. Alerts generated outside the window do not run the action. A zone such as
Europe/Madridfollows daylight saving time;UTC+1does not and the reference recommends against it.
When both are set, both must be met. Typical uses are a pager action that fires only for production hosts and only on business days, while a chat action with no conditions runs always. These conditions filter the action, not the alert: the alert still exists, still shows in the alerts table and still reaches every action without the gate. If a gate never matches, the action silently never runs, so test the query in Discover against the alert indices first.
"alerts_filter": {
"query": { "kql": "host.name : \"web-01\"", "filters": [] },
"timeframe": {
"days": [1, 2, 3, 4, 5],
"hours": { "start": "08:00", "end": "20:00" },
"timezone": "Europe/Madrid"
}
}
The fragment goes inside an action object next to group, id, params and frequency; the complete rule below shows
where. The reference marks filters as required inside query, so keep the empty array when you give only a kql string.
Sources: Custom threshold rule: action frequency
(the two UI conditions) and the Create a rule
API reference (alerts_filter.query.kql, alerts_filter.timeframe). The Stack Management rule flyout page does not describe
these conditions, so check that a given rule type offers them in its flyout.
Action variables
The params of every action are Mustache templates. The rule type decides which values exist, and the add rule variable button in the flyout lists exactly those for the rule you are editing. Common values exist for all rule types, and the rest depend on the frequency.
| Variable | Meaning |
|---|---|
|
When the rule scheduled the action, in ISO format. |
|
The value of |
|
Identifier, name, space and tags of the rule. |
|
The rule’s own parameters, which vary by rule type (for example |
|
Link to the rule that generated the alert; empty without |
Per-alert actions add:
| Variable | Meaning |
|---|---|
|
The alert identifier; the UUID stays the same while the alert is active. |
|
Identifier and display name of the action group, and the subgroup. |
|
Consecutive runs that met the conditions. |
|
Whether the alert is flapping. |
|
Values added by the rule type, named after the rule type’s own list: |
Summary actions replace those with the collections alerts.all, alerts.new, alerts.ongoing and alerts.recovered; each has
.count (a number) and .data (an array of alert objects). The properties of each .data object that the page lists include
kibana.alert.start, kibana.alert.end, kibana.alert.flapping, kibana.alert.instance.id, kibana.alert.reason and
kibana.alert.status; the page marks that property list as preview and says it is not complete.
The rule-specific values are the part to learn per rule type. The custom threshold rule provides, among others,
context.alertDetailsUrl, context.reason, context.value, context.grouping, context.timestamp and
context.viewInAppUrl. The SLO burn rate rule provides context.sloName, context.sloId, context.sloInstanceId,
context.burnRateThreshold, context.longWindow, context.shortWindow, context.reason and the same links. The log threshold
rule adds the time period over which the conditions were met. A message that includes {{context.reason}} and the two links
is already a good default: it says what is wrong and where to look.
{{rule.name}} is {{alert.actionGroupName}} for {{context.grouping}}
Reason: {{context.reason}}
Alert details: {{context.alertDetailsUrl}}
Open in app: {{context.viewInAppUrl}}
Sources: Rule action variables, Custom threshold rule: action variables, SLO burn rate rule: action variables, Log threshold rule: action variables.
Escaping and triple braces
Two braces insert a value and escape it where the connector needs escaping; three braces insert it as it is. The escaping depends
on the connector: the e-mail and Slack message properties escape Markdown characters, and the Webhook body property
escapes characters that are invalid in a JSON string, such as double quotes. That is why a webhook body written as
{ "reason": "{{context.reason}}" }
stays valid JSON even when the reason contains quotes, and the same body with {{{context.reason}}} can produce broken JSON
and a failed action. Use triple braces only when you need the raw value and know the target tolerates it: for example inside
the lambdas below, or when the value is itself a JSON fragment. The page warns that triple braces can produce invalid or
malformed output.
Objects render as JSON, {{context}} renders everything the rule type provides, and {{.}} renders every variable of the
alert. To loop over an array use a section: {{#context.hits}}...{{/context.hits}} for the hits of a search rule, with fields
such as {{_source.message}} inside. To see what a rule really provides, put {{{.}}} as the whole body of a webhook or
e-mail action, run the rule once, and read the JSON that arrives: it contains alertId, alertName, spaceId, context,
date, kibanaBaseUrl, params, rule and alert. This is the fastest way to debug a missing variable.
Lambdas and asJSON (technical preview)
The page marks the following as technical preview, which may change or be removed and is outside the support SLA of GA features;
do not build the only notification path on it. Arrays render as comma-joined strings by default ([1, 4, 9] becomes 1,4,9);
adding asJSON after a variable name renders a real JSON array. Lambdas wrap a section, {{#Name}}...{{/Name}}:
| Lambda | What it does |
|---|---|
|
Evaluates a TinyMath expression. Variables inside need no braces; use triple braces for string-typed values. |
|
Lets a template write JSON in Hjson (comments, unquoted keys, trailing commas, dedented multi-line strings), which makes long JSON bodies readable. Plain JSON works too. |
|
Takes |
|
Wraps |
Fired at {{#FormatDate}}{{{date}}}; Europe/Madrid; YYYY-MM-DD HH:mm{{/FormatDate}}
Value: {{#EvalMath}}round(context.value, 1){{/EvalMath}}
Pretty: {{#FormatNumber}}{{context.value}}; en-US; maximumFractionDigits:1{{/FormatNumber}}
The three lines assume a rule type whose context.value is a single number, such as the Elasticsearch query rule. The custom
threshold rule reports a list of condition values, so format them with the section syntax or with asJSON instead. The page’s
own examples show the same lambdas combined (a rounded value multiplied with EvalMath and then formatted as currency) and a
complete e-mail template for an Elasticsearch query rule that loops over its hits.
A complete rule for the lab
The rule below ties the pieces together. It is an Elasticsearch query rule on ES|QL that looks at the Bookshelf error logs, with
four actions on two connectors: a per-alert webhook on status changes, a recovery webhook, a summary line to the Kibana server
log once an hour, and the custom-interval reminder. The connectors bookshelf-webhook (webhook to
http://webhook-receiver:8080/kibana) and bookshelf-server-log must exist first; creating them is the first lab step of
Connectors.
curl -s -u "elastic:${ELASTIC_PASSWORD}" -X POST "http://localhost:5601/s/bookshelf/api/alerting/rule/bookshelf-error-logs" \
-H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '{
"name": "Bookshelf error logs",
"rule_type_id": ".es-query",
"consumer": "stackAlerts",
"schedule": { "interval": "1m" },
"tags": ["bookshelf", "team:bookshelf-sre"],
"params": {
"searchType": "esqlQuery",
"esqlQuery": { "esql": "FROM logs-* | WHERE service.name == \"bookshelf\" AND severity_text == \"ERROR\" | STATS errors = COUNT(*) | WHERE errors > 20" },
"timeField": "@timestamp",
"timeWindowSize": 5,
"timeWindowUnit": "m",
"size": 0,
"threshold": [0],
"thresholdComparator": ">"
},
"actions": [
{
"id": "bookshelf-webhook",
"group": "query matched",
"frequency": { "notify_when": "onActionGroupChange", "summary": false },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"alert\":\"{{alert.id}}\",\"state\":\"{{alert.actionGroupName}}\",\"value\":\"{{context.value}}\",\"conditions\":\"{{context.conditions}}\",\"link\":\"{{context.link}}\",\"space\":\"{{rule.spaceId}}\"}" }
},
{
"id": "bookshelf-webhook",
"group": "recovered",
"frequency": { "notify_when": "onActionGroupChange", "summary": false },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"alert\":\"{{alert.id}}\",\"state\":\"recovered\",\"space\":\"{{rule.spaceId}}\"}" }
},
{
"id": "bookshelf-server-log",
"group": "query matched",
"frequency": { "notify_when": "onThrottleInterval", "throttle": "1h", "summary": true },
"params": { "level": "info", "message": "{{rule.name}}: {{alerts.new.count}} new, {{alerts.ongoing.count}} ongoing, {{alerts.recovered.count}} recovered" }
},
{
"id": "bookshelf-server-log",
"group": "query matched",
"frequency": { "notify_when": "onThrottleInterval", "throttle": "5m", "summary": false },
"params": { "level": "warn", "message": "Still failing: {{rule.name}} ({{alert.id}}) {{rule.url}}" }
}
]
}'
The environment variable ELASTIC_PASSWORD is the lab’s, defined with the compose file on
Installation & Configuration; a service
account API key in an Authorization: ApiKey header is the better choice outside the lab. The field names service.name and
severity_text are those of the lab’s OTLP data and the 20-error threshold is the lab’s: for other data confirm the real field names in Discover (see
Data Views & Discover), and note that the lab’s five alerts
use the thresholds of the canonical lab values (5xx ratio 0.05, p95 0.5 s), which belong to the rules on
Observability Rules. The link variables are empty unless
server.publicBaseUrl is configured (the lab compose sets it). The complete set of alerting API calls, and the Terraform
resource for the same rule, are on
Alerting APIs & Terraform.
Reference: Create a rule
(request body, actions, frequency, group), and the same page’s examples for the Elasticsearch query rule.
What can go wrong
-
A notification storm from check-interval frequency. A per-alert action on check intervals notifies again at every check for every alert that is still active. Choose status changes or a custom interval, or use a summary.
-
No recovery message. Only actions in the recovered group fire when the alert clears. Add one per connector that opened something (an Opsgenie alert, a PagerDuty incident), otherwise tickets stay open.
-
Empty links.
kibanaBaseUrl,rule.url,context.alertDetailsUrlandcontext.viewInAppUrlare empty withoutserver.publicBaseUrl. -
Broken JSON in a webhook. Triple braces or a hand-built body with an unescaped value breaks the JSON and the action fails; the failure is visible only on the rule’s History tab (Errored actions) and in the event log, not in the alerts table.
-
Variables from the wrong frequency.
alerts.new.countis empty in a per-alert action andalert.idin a summary action. -
Conditions that never match. An
alerts_filterquery on a field the alert document does not contain suppresses the action without any error. -
Deleted connector. A connector can be deleted while actions still reference it; the action then fails to run and the errors appear in the Kibana logs.
-
Lambdas in production. They are technical preview; a version upgrade may change them.
Verify it in the lab
-
Start the
kibanaprofile with thewebhook-receiverand create the connectors of the Connectors page. -
Create a scratch rule with one webhook action whose body is exactly
{{{.}}}, set to run on check intervals, and run it against failing traffic. Indocker compose logs webhook-receiverread the JSON that arrives and note whichcontextfields your rule type provides. Delete the action afterwards. -
Create the rule above (adjust the field names to what Discover shows). Switch the load generator to failing-request mode and watch the receiver: one
query matchedmessage at the start and nothing at the next minutes, then the reminder every five minutes in the Kibana log (docker compose logs kibana), then the recovered message when you stop the errors. -
Change the first action to On check intervals for ten minutes and count the messages; compare with the table above, then restore status changes.
-
Add the
alerts_filterfragment with a query that cannot match and confirm that the action stays silent while the alert still appears in the alerts table; then remove it. -
Open the rule’s History tab and, after breaking the webhook URL on purpose, find the entry under Errored actions.
In the books
Shah, Kibana 8.x Quick Start Guide, chapter 6 (section "Setting up alerts"), creates an anomaly detection rule and then a connector in the 8.x user interface, as two separate steps, and notes that the action can be an e-mail or a Slack message. The model of this page (action groups, summary actions, frequency per action, conditional actions, Mustache variables and lambdas) is not in that chapter, and the screens have changed since: in 9.x the connector is chosen inside the rule flyout and every action carries its own frequency. Publisher pages are listed in the bibliography of the section index.