Kibana: Bookshelf End to End
|
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, Kibana 9.5.6 and the EDOT Collector 9.5.6 in the hands-on lab, on the self-generated trial licence.
The Kibana pages explain the parts one by one: data, dashboards, rules, connectors, SLOs, maintenance windows. This page puts them together for the lab service Bookshelf, using one script that calls the Kibana APIs, and then breaks the service on purpose. At the end you have the "Bookshelf service health" dashboard and five alerts, you have seen each alert reach the webhook receiver, and you have a table that sets Kibana against what Grafana: Bookshelf End to End did for the same service.
It runs in the kibana profile of the hands-on lab. Two licence facts matter here: the webhook connector needs a
Gold or higher subscription and maintenance windows need Platinum, so the lab starts a self-generated trial licence (xpack.license.self_generated.type=trial on
Elasticsearch, 30 days); on a Basic licence the script’s connector and maintenance window requests are refused.
What gets built
| Alert (rule id) | Rule type and condition | Action group notified | How the lab breaks it |
|---|---|---|---|
Bookshelf high 5xx ratio ( |
Custom threshold on the data view |
|
|
Bookshelf p95 latency above SLO ( |
APM latency threshold: service |
|
|
Bookshelf no data ( |
Custom threshold: count of |
|
|
Bookshelf error-log spike ( |
Elasticsearch query rule (KQL) on the data view |
|
|
Bookshelf availability burn rate ( |
SLO burn rate rule on the SLO |
|
|
The thresholds are the lab values used across this section: 0.05 for the 5xx ratio and 0.5 s (500 ms) for the latency objective. All rules are tagged bookshelf (the maintenance window scope relies on that tag), live in the space bookshelf and send to the connector bookshelf-webhook, which posts JSON to http://webhook-receiver:8080/kibana.
Start the lab and create everything
cd lab
docker compose --profile kibana up -d
until curl -fsS http://localhost:5601/api/status >/dev/null; do sleep 5; done
# let the load generator produce a minute of data, then:
bash kibana/setup.sh
The script is idempotent only in the sense that a second run reports conflicts for objects that exist; run docker compose down -v for a clean start. It reads
ELASTIC_PASSWORD (default lab-elastic-password) and KIBANA_URL from the environment and uses the elastic user for brevity. In a real installation use a service
user or an API key, because that user’s privileges become the privileges of every rule it saves (see
Alerting Setup, Security & Scaling). Each request in it is explained, with its official reference, on the page named next to it:
| Step | Where it is explained |
|---|---|
Space |
|
Data views |
|
Webhook connector |
|
Custom threshold, APM latency and no-data rules |
|
Elasticsearch query rule for the error-log spike |
|
SLO, burn rate rule and maintenance window |
|
Dashboard |
kibana/setup.sh
#!/usr/bin/env bash
# Creates the Kibana objects of the Bookshelf lab in the space "bookshelf": space, data views, webhook connector,
# the five alert rules, an availability SLO, a maintenance window and the dashboard.
# Run it once, after Kibana is ready and the load generator has produced some data. Needs curl and jq.
set -euo pipefail
cd "$(dirname "$0")"
export ELASTIC_PASSWORD="${ELASTIC_PASSWORD:-lab-elastic-password}"
export KIBANA_URL="${KIBANA_URL:-http://localhost:5601}"
export KIBANA="$KIBANA_URL/s/bookshelf"
export KAUTH="elastic:$ELASTIC_PASSWORD"
api() { curl -sS -u "$KAUTH" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' "$@"; }
echo "== space"
api -X POST "$KIBANA_URL/api/spaces/space" -d '{
"id": "bookshelf", "name": "Bookshelf",
"description": "Bookshelf service dashboards, rules and connectors", "solution": "oblt"
}' | jq -c '{id, solution}'
echo "== data views"
api -X POST "$KIBANA/api/data_views/data_view" -d '{"data_view":{"id":"bookshelf-traces","name":"Bookshelf traces","title":"traces-*","timeFieldName":"@timestamp"}}' | jq -c '.data_view.id'
api -X POST "$KIBANA/api/data_views/data_view" -d '{"data_view":{"id":"bookshelf-logs","name":"Bookshelf logs (OTel)","title":"logs-*.otel-*","timeFieldName":"@timestamp"}}' | jq -c '.data_view.id'
echo "== connector"
api -X POST "$KIBANA/api/actions/connector/bookshelf-webhook" -d '{
"name": "bookshelf-webhook",
"connector_type_id": ".webhook",
"config": {
"url": "http://webhook-receiver:8080/kibana",
"method": "post",
"hasAuth": false,
"headers": { "Content-Type": "application/json" }
}
}' | jq -c '{id, is_missing_secrets}'
echo "== helpers that read the action group ids of the rule types"
types() { curl -s -u elastic:"$ELASTIC_PASSWORD" "$KIBANA_URL/s/bookshelf/api/alerting/rule_types"; }
default_group() { types | jq -r --arg t "$1" '.[] | select(.id == $t) | .default_action_group_id'; }
group_named() { types | jq -r --arg t "$1" --arg n "$2" '.[] | select(.id == $t) | .action_groups[] | select(.name | ascii_downcase == $n) | .id'; }
echo "== rule: high 5xx ratio"
CT=observability.rules.custom_threshold
curl -s -u elastic:"$ELASTIC_PASSWORD" -X POST "$KIBANA_URL/s/bookshelf/api/alerting/rule/bookshelf-5xx-ratio" \
-H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @- <<JSON
{
"name": "Bookshelf high 5xx ratio",
"rule_type_id": "$CT",
"consumer": "alerts",
"tags": ["bookshelf", "bookshelf-sre"],
"schedule": { "interval": "1m" },
"params": {
"criteria": [
{
"aggType": "custom",
"comparator": ">",
"threshold": [0.05],
"timeSize": 5,
"timeUnit": "m",
"equation": "A / B",
"label": "5xx ratio",
"metrics": [
{ "name": "A", "aggType": "count", "filter": "service.name: \"bookshelf\" and http.response.status_code >= 500" },
{ "name": "B", "aggType": "count", "filter": "service.name: \"bookshelf\"" }
]
}
],
"searchConfiguration": { "index": "bookshelf-traces", "query": { "language": "kuery", "query": "" } },
"alertOnNoData": false,
"alertOnGroupDisappear": false
},
"actions": [
{
"id": "bookshelf-webhook",
"group": "$(group_named $CT alert)",
"frequency": { "summary": false, "notify_when": "onActionGroupChange", "throttle": null },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"reason\":\"{{context.reason}}\",\"url\":\"{{context.viewInAppUrl}}\"}" }
}
]
}
JSON
echo
echo "== rule: p95 latency above SLO"
APM=apm.transaction_duration
curl -s -u elastic:"$ELASTIC_PASSWORD" -X POST "$KIBANA_URL/s/bookshelf/api/alerting/rule/bookshelf-p95-latency" \
-H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @- <<JSON
{
"name": "Bookshelf p95 latency above SLO",
"rule_type_id": "$APM",
"consumer": "apm",
"tags": ["bookshelf", "bookshelf-sre"],
"schedule": { "interval": "1m" },
"params": {
"serviceName": "bookshelf",
"transactionType": "request",
"environment": "lab",
"aggregationType": "95th",
"threshold": 500,
"windowSize": 5,
"windowUnit": "m",
"groupBy": ["service.name", "service.environment"]
},
"actions": [
{
"id": "bookshelf-webhook",
"group": "$(default_group $APM)",
"frequency": { "summary": false, "notify_when": "onActionGroupChange", "throttle": null },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"service\":\"{{context.serviceName}}\",\"value\":\"{{context.triggerValue}}\",\"threshold\":\"{{context.threshold}}\"}" }
}
]
}
JSON
echo
echo "== rule: no data"
curl -s -u elastic:"$ELASTIC_PASSWORD" -X POST "$KIBANA_URL/s/bookshelf/api/alerting/rule/bookshelf-no-data" \
-H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @- <<JSON
{
"name": "Bookshelf no data",
"rule_type_id": "$CT",
"consumer": "alerts",
"tags": ["bookshelf", "bookshelf-sre"],
"schedule": { "interval": "1m" },
"params": {
"criteria": [
{
"aggType": "custom",
"comparator": "<",
"threshold": [1],
"timeSize": 5,
"timeUnit": "m",
"equation": "A",
"label": "requests",
"metrics": [ { "name": "A", "aggType": "count", "filter": "service.name: \"bookshelf\"" } ]
}
],
"searchConfiguration": { "index": "bookshelf-traces", "query": { "language": "kuery", "query": "" } },
"noDataBehavior": "alertOnNoData"
},
"actions": [
{
"id": "bookshelf-webhook",
"group": "$(group_named $CT 'no data')",
"frequency": { "summary": false, "notify_when": "onActionGroupChange", "throttle": null },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"reason\":\"{{context.reason}}\"}" }
},
{
"id": "bookshelf-webhook",
"group": "$(group_named $CT alert)",
"frequency": { "summary": false, "notify_when": "onActionGroupChange", "throttle": null },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"reason\":\"{{context.reason}}\"}" }
}
]
}
JSON
echo
echo "== rule: error-log spike"
curl -s -u elastic:"$ELASTIC_PASSWORD" -X POST "$KIBANA_URL/s/bookshelf/api/alerting/rule/bookshelf-error-log-spike" \
-H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '{
"name": "Bookshelf error-log spike",
"rule_type_id": ".es-query",
"consumer": "stackAlerts",
"tags": ["bookshelf", "bookshelf-sre"],
"schedule": { "interval": "1m" },
"params": {
"searchType": "searchSource",
"searchConfiguration": {
"index": "bookshelf-logs",
"query": { "language": "kuery", "query": "severity_text: \"ERROR\"" }
},
"aggType": "count",
"groupBy": "all",
"excludeHitsFromPreviousRun": false,
"size": 10,
"threshold": [20],
"thresholdComparator": ">",
"timeWindowSize": 5,
"timeWindowUnit": "m"
},
"actions": [
{
"id": "bookshelf-webhook",
"group": "query matched",
"frequency": { "summary": false, "notify_when": "onActionGroupChange", "throttle": null },
"params": {
"body": "{\"rule\":\"{{rule.name}}\",\"value\":\"{{context.value}}\",\"conditions\":\"{{context.conditions}}\",\"link\":\"{{context.link}}\"}"
}
}
]
}'
echo
echo "== SLO and its burn rate rule"
api -X POST "$KIBANA/api/observability/slos" -d '{
"id": "bookshelf-availability",
"name": "Bookshelf availability",
"description": "99.5 percent of requests succeed over 30 days",
"indicator": {
"type": "sli.kql.custom",
"params": {
"index": "traces-*",
"timestampField": "@timestamp",
"filter": "service.name : \"bookshelf\"",
"good": "http.response.status_code < 500",
"total": "http.response.status_code : *"
}
},
"timeWindow": { "duration": "30d", "type": "rolling" },
"budgetingMethod": "occurrences",
"objective": { "target": 0.995 },
"tags": ["bookshelf", "lab"]
}'
echo
api -X POST "$KIBANA/api/alerting/rule/bookshelf-slo-burn-rate" -d '{
"name": "Bookshelf availability burn rate",
"rule_type_id": "slo.rules.burnRate",
"consumer": "slo",
"schedule": { "interval": "1m" },
"tags": ["bookshelf", "lab"],
"params": {
"sloId": "bookshelf-availability",
"windows": [
{ "id": "w-1h", "burnRateThreshold": 14.4, "longWindow": { "value": 1, "unit": "h" }, "shortWindow": { "value": 5, "unit": "m" }, "actionGroup": "slo.burnRate.alert" },
{ "id": "w-6h", "burnRateThreshold": 6, "longWindow": { "value": 6, "unit": "h" }, "shortWindow": { "value": 30, "unit": "m" }, "actionGroup": "slo.burnRate.high" },
{ "id": "w-24h", "burnRateThreshold": 3, "longWindow": { "value": 24, "unit": "h" }, "shortWindow": { "value": 2, "unit": "h" }, "actionGroup": "slo.burnRate.medium" },
{ "id": "w-72h", "burnRateThreshold": 1, "longWindow": { "value": 72, "unit": "h" }, "shortWindow": { "value": 6, "unit": "h" }, "actionGroup": "slo.burnRate.low" }
]
},
"actions": [
{
"id": "bookshelf-webhook", "group": "slo.burnRate.alert",
"frequency": { "notify_when": "onActionGroupChange", "summary": false },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"status\":\"critical burn\",\"reason\":\"{{context.reason}}\",\"link\":\"{{context.alertDetailsUrl}}\"}" }
},
{
"id": "bookshelf-webhook", "group": "slo.burnRate.high",
"frequency": { "notify_when": "onActionGroupChange", "summary": false },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"status\":\"high burn\",\"reason\":\"{{context.reason}}\"}" }
},
{
"id": "bookshelf-webhook", "group": "recovered",
"frequency": { "notify_when": "onActionGroupChange", "summary": false },
"params": { "body": "{\"rule\":\"{{rule.name}}\",\"status\":\"recovered\"}" }
}
]
}'
echo
echo "== maintenance window"
api -X POST "$KIBANA/api/maintenance_window" -d '{
"title": "Bookshelf weekly deploy",
"enabled": true,
"schedule": {
"custom": {
"start": "2026-11-15T22:00:00.000Z",
"duration": "1h",
"timezone": "UTC",
"recurring": { "every": "1w", "onWeekDay": ["SU"] }
}
},
"scope": { "alerting": { "query": { "kql": "kibana.alert.rule.tags : \"bookshelf\"" } } }
}'
echo
echo "== dashboard"
api -X PUT "$KIBANA/api/dashboards/bookshelf-service-health" -d @bookshelf-service-health.json | jq -c '{id}'
The action group ids in the script are not guessed: the helper functions read them from GET /s/bookshelf/api/alerting/rule_types. On Kibana 9.5.6 that endpoint lists
custom_threshold.fired, custom_threshold.warning, custom_threshold.nodata and recovered for the custom threshold rule, threshold_met for the APM latency rule,
query matched for the Elasticsearch query rule and slo.burnRate.alert, slo.burnRate.high, slo.burnRate.medium, slo.burnRate.low and slo.burnRate.suppressed for
the burn rate rule.
The field names of the lab data
The stand-in sends OpenTelemetry data and the EDOT Collector writes it in the OTel-native mapping, so the documents keep OpenTelemetry names. A trace document has
@timestamp, duration in nanoseconds, name, attributes.http.response.status_code, attributes.http.route, attributes.url.path and, added by the elasticapm
processor, attributes.transaction.duration.us; the resource attributes are under resource.attributes.*. Passthrough fields make the short names work in KQL, ES|QL and
data views, so the queries in this page use service.name, http.response.status_code and url.path. A log document has body.text, severity_text (INFO or ERROR),
severity_number, trace_id and span_id; it has no log.level, which is the ECS name, and the Bookshelf JSON fields uri and status are under attributes.*. The Collector
also writes the aggregated APM metrics (metrics-service_summary.1m.otel-default, metrics-service_transaction.1m.otel-default, metrics-transaction.1m.otel-default) that the APM
latency rule and the Applications UI read. See Ingesting Monitoring Data.
Check them before writing a query:
curl -s -u elastic:lab-elastic-password 'http://localhost:9200/traces-*/_field_caps?fields=service.name,http.response.status_code,transaction.duration.us&filter_path=fields.*.*.type'
curl -s -u elastic:lab-elastic-password -H 'Content-Type: application/json' http://localhost:9200/_query -d '{"query":"FROM traces-* | WHERE service.name == \"bookshelf\" | STATS errors = COUNT(*) WHERE http.response.status_code >= 500, total = COUNT(*) | EVAL ratio = TO_DOUBLE(errors) / total | KEEP ratio"}'
The dashboard
The dashboard is one JSON object sent with PUT /s/bookshelf/api/dashboards/bookshelf-service-health, so the same command creates it the first time and replaces it afterwards. It
has a pinned options-list control on service.name, a markdown header, four metric panels, two time series and a collapsed "Dependencies" section. Every panel is an ES|QL
panel, so no data view or library visualization has to exist for it (the control is the one object that refers to the data view bookshelf-traces):
| Panel | ES|QL |
|---|---|
Requests |
|
5xx ratio |
|
p95 latency (s) |
|
ERROR log lines |
|
Requests over time, 5xx responses over time |
|
The six queries were run against the lab (through the _query API with ?_tstart and ?_tend supplied) and returned values for the live traffic. The stand-in exports no
metrics to Elasticsearch, so the Dependencies section holds a markdown note where the Grafana dashboard has the JVM heap and connection pool panels. The request carries no access_control
property: with "access_control": { "access_mode": "write_restricted" } and basic authentication, Kibana answered 500 and logged that it could not determine the user profile ID of the
caller.
kibana/bookshelf-service-health.json
{
"title": "Bookshelf service health",
"description": "RED overview of the Bookshelf service (lab)",
"time_range": {
"from": "now-6h",
"to": "now"
},
"refresh_interval": {
"pause": false,
"value": 30000
},
"query": {
"language": "kql",
"expression": ""
},
"pinned_panels": [
{
"type": "options_list_control",
"width": "medium",
"grow": false,
"config": {
"title": "Service",
"data_view_id": "bookshelf-traces",
"field_name": "service.name"
}
}
],
"panels": [
{
"grid": {
"x": 0,
"y": 0,
"w": 48,
"h": 4
},
"type": "markdown",
"config": {
"content": "## Bookshelf service health\n\nGolden signals from traces and logs. Alert thresholds: 5xx ratio 0.05, p95 0.5 s. Runbook: https://wiki.example.com/bookshelf/runbooks"
}
},
{
"grid": {
"x": 0,
"y": 4,
"w": 12,
"h": 6
},
"type": "vis",
"config": {
"type": "metric",
"title": "Requests",
"data_source": {
"type": "esql",
"query": "FROM traces-* | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend AND service.name == \"bookshelf\" | STATS requests = COUNT(*)"
},
"metrics": [
{
"type": "primary",
"column": "requests"
}
]
}
},
{
"grid": {
"x": 12,
"y": 4,
"w": 12,
"h": 6
},
"type": "vis",
"config": {
"type": "metric",
"title": "5xx ratio",
"data_source": {
"type": "esql",
"query": "FROM traces-* | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend AND service.name == \"bookshelf\" | STATS errors = COUNT(*) WHERE http.response.status_code >= 500, total = COUNT(*) | EVAL ratio = TO_DOUBLE(errors) / total | KEEP ratio"
},
"metrics": [
{
"type": "primary",
"column": "ratio"
}
]
}
},
{
"grid": {
"x": 24,
"y": 4,
"w": 12,
"h": 6
},
"type": "vis",
"config": {
"type": "metric",
"title": "p95 latency (s)",
"data_source": {
"type": "esql",
"query": "FROM traces-* | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend AND service.name == \"bookshelf\" | STATS p95 = PERCENTILE(duration, 95) | EVAL p95_s = p95 / 1000000000.0 | KEEP p95_s"
},
"metrics": [
{
"type": "primary",
"column": "p95_s"
}
]
}
},
{
"grid": {
"x": 36,
"y": 4,
"w": 12,
"h": 6
},
"type": "vis",
"config": {
"type": "metric",
"title": "ERROR log lines",
"data_source": {
"type": "esql",
"query": "FROM logs-* | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend AND service.name == \"bookshelf\" AND severity_text == \"ERROR\" | STATS error_lines = COUNT(*)"
},
"metrics": [
{
"type": "primary",
"column": "error_lines"
}
]
}
},
{
"grid": {
"x": 0,
"y": 10,
"w": 24,
"h": 12
},
"type": "vis",
"config": {
"type": "xy",
"title": "Requests over time",
"layers": [
{
"type": "line",
"data_source": {
"type": "esql",
"query": "FROM traces-* | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend AND service.name == \"bookshelf\" | STATS requests = COUNT() BY BUCKET(@timestamp, 75, ?_tstart, ?_tend)"
},
"x": {
"column": "BUCKET(@timestamp, 75, ?_tstart, ?_tend)"
},
"y": [
{
"column": "requests"
}
]
}
],
"axis": {
"x": {
"title": {
"visible": false
}
}
}
}
},
{
"grid": {
"x": 24,
"y": 10,
"w": 24,
"h": 12
},
"type": "vis",
"config": {
"type": "xy",
"title": "5xx responses over time",
"layers": [
{
"type": "line",
"data_source": {
"type": "esql",
"query": "FROM traces-* | WHERE @timestamp >= ?_tstart AND @timestamp < ?_tend AND service.name == \"bookshelf\" AND http.response.status_code >= 500 | STATS errors = COUNT() BY BUCKET(@timestamp, 75, ?_tstart, ?_tend)"
},
"x": {
"column": "BUCKET(@timestamp, 75, ?_tstart, ?_tend)"
},
"y": [
{
"column": "errors"
}
]
}
],
"axis": {
"x": {
"title": {
"visible": false
}
}
}
}
},
{
"title": "Dependencies",
"collapsed": true,
"grid": {
"y": 22
},
"panels": [
{
"grid": {
"x": 0,
"y": 0,
"w": 24,
"h": 8
},
"type": "markdown",
"config": {
"content": "JVM heap and connection pool panels go here. The lab stand-in exports no metrics to Elasticsearch."
}
}
]
}
]
}
Reference: Kibana API: Dashboards and
Kibana: Manage dashboards as code. Open the dashboard in the bookshelf space under
Dashboards. With the load generator running expect about 10 requests per second, a 5xx ratio of 0 and a p95 around 0.2 s.
The SLO and its burn rate rule
The availability SLO is a custom KQL indicator on the trace documents (good: http.response.status_code < 500, total: http.response.status_code : *), 99.5 percent over a
rolling 30 days, budgeting by occurrences. Two transforms are created for it (slo-bookshelf-availability-1 and slo-summary-bookshelf-availability-1; check them with
GET _transform). The first attempt used the APM availability indicator over metrics-*, which is what the SLO page describes for APM data; on the lab’s OpenTelemetry metrics it
reported an SLI of 1 and a burn rate of 400 whatever the failure rate, so the lab uses the KQL indicator, whose value fell to 0.92 within a minute of the failing mode.
The burn rate rule has four windows (1 hour and 5 minutes at 14.4, 6 hours and 30 minutes at 6, 24 hours and 2 hours at 3, 72 hours and 6 hours at 1). Only the critical and high groups and the recovery notify the webhook; the other two are visible on the Alerts page. Grafana’s lab rule uses the first pair only.
The maintenance window
The window "Bookshelf weekly deploy" repeats weekly on Sundays at 22:00 UTC for one hour and has the KQL scope kibana.alert.rule.tags : "bookshelf", so it covers all five rules. While it is
active, alerts are still created but their notifications are suppressed, including recovery notifications for alerts that fired during the window. The request was accepted and the
window reports the status upcoming; the lab does not wait for Sunday, so suppression itself was not exercised.
Break the service and watch
Run these in order, with the receiver open in a second terminal (docker compose logs -f --no-log-prefix webhook-receiver). The times were measured on the lab for this page, from
the moment the load generator changed mode to the first delivery at the receiver.
| Step | Command | First notification | What you see |
|---|---|---|---|
1. Break with 5xx errors |
|
Error-log spike after 1 min 9 s; high 5xx ratio after 1 min 15 s |
The rules run every minute and the 5 minute window fills with failures, so both are active in the first runs after the switch; there is no pending state. The SLO burn rate rule was created two minutes after the switch and its first notification (critical, 1 hour and 5 minute burn rate 15.88 against 14.4) arrived 2 min after creation, which includes the start-up of the SLO’s transforms. |
2. Return to normal |
|
None |
The 5xx and error-log alerts recovered within 5 min 30 s, when the failures left the 5 minute window, and the rules showed no active alerts. No recovered message was sent, because the script gives these rules no action for the |
3. Slow responses |
|
p95 latency above SLO after 2 min 24 s (value 1,278 ms against 500) |
The APM latency rule reads the aggregated metrics from the Collector. In the same period the burn rate rule’s second window crossed its threshold, because the failures of the first step were still inside the 6 hour and 30 minute windows: a |
4. Errors in the log only |
|
Error-log spike after 1 min 4 s |
Responses stay 200, so only the log rule reacts; the p95 alert from the previous step recovered in the same period. |
5. Stop the service |
|
No data after 5 min 25 s |
The count of |
Times are minutes after the load generator changed mode (or after the containers stopped), measured from the receiver log of one run; the rules run every minute.
What the receiver gets
Each delivery is a JSON body built by the Mustache template of the rule’s action, one WEBHOOK line in the receiver log. The ones the lab produced:
{"rule":"Bookshelf high 5xx ratio","reason":"5xx ratio is 0.19517, above the threshold of 0.05. (duration: 5 mins, data view: Bookshelf traces)","url":"http://localhost:5601/s/bookshelf/app/r?l=DISCOVER_APP_LOCATOR&v=9.5.6&lz=..."}
{"rule":"Bookshelf p95 latency above SLO","service":"bookshelf","value":"1,278 ms","threshold":"500"}
{"rule":"Bookshelf no data","reason":"requests reported no data in the last 5m"}
{"rule":"Bookshelf error-log spike","value":"468","conditions":"Number of matching documents is greater than 20","link":"http://localhost:5601/s/bookshelf/app/r?l=DISCOVER_APP_LOCATOR&v=9.5.6&lz=..."}
{"rule":"Bookshelf availability burn rate","status":"critical burn","reason":"CRITICAL: The burn rate for the past 1h is 15.88 and for the past 5m is 15.88. Alert when above 14.4 for both windows","link":"http://localhost:5601/s/bookshelf/app/observability/..."}
The links are shortened here; they open Discover or the alert details in the bookshelf space and work because SERVER_PUBLICBASEURL is set to http://localhost:5601 in the Compose file. Read the deliveries with:
docker compose logs --no-log-prefix webhook-receiver | grep WEBHOOK
curl -s localhost:8081 | jq -r '.[] | "\(.time) \(.path)"'
The reason text is free text with quotes and colons in it, so a receiver that parses the body as JSON must tolerate that, as explained on
Actions, Frequency & Action Variables.
Kibana and Grafana side by side
| Aspect | Grafana (Grafana 13.3.0) | Kibana (9.5.6) |
|---|---|---|
Where the lab data lives |
Prometheus (metrics), Loki (logs), Tempo (traces), three data sources |
Elasticsearch data streams (traces, logs, aggregated APM metrics), data views or ES|QL |
Query languages used |
PromQL and LogQL |
KQL for the rule filters, ES|QL for the dashboard panels |
Dashboard as code |
Classic JSON file loaded by a file provider; the file is the source of truth |
Dashboards API JSON sent with |
Five alerts as code |
One provisioning file with two rule groups; a rule is a query, a Reduce and a Threshold or Math expression |
Five |
Pending period |
Per rule ( |
None on the rule types used here: the rule fires when the condition is met in a run (an |
SLO burn rate |
One rule with two PromQL queries and a Math expression, on the raw metric |
A first-class SLO object with generated transforms, and a burn rate rule with four windows |
Missing data |
|
|
Routing |
Policy tree with matchers, group wait, group interval and repeat interval |
Each rule’s actions name the connector and the action group directly; frequency is per action (on status change in the lab) |
Notification content |
Go template group |
Mustache in the connector action body ( |
Resolved notifications |
Sent with the group’s next interval (1 minute for critical, 5 for warning in the lab tree) |
Sent only if the rule has an action for the |
Where the two tools were measured on the same service, the first notification arrived within about two and a half minutes of the 5xx failures in Grafana (2 minute pending period) and about one and a quarter minutes in Kibana, which has no pending period; both resolved the 5xx alert only after the five-minute window drained. The comparison of the concepts, term by term, is on the glossary and the comparison page of this section.
What can go wrong
-
The field is
severity_text, notlog.level. OTLP logs carry the OpenTelemetry level field; a KQL filter on the ECS name matches nothing and the error-log rule never fires. -
access_controlmakes the dashboard request fail. With basic authentication the request that includes"access_control": { "access_mode": "write_restricted" }answered 500, and the Kibana log said it could not determine the user profile ID of the caller. -
The APM availability SLO shows nonsense on OpenTelemetry metrics. It reported an SLI of 1 and a burn rate of 400 regardless of the failures; the KQL indicator on
traces-*reflects them. -
The machine learning job does not open in the 2 GB lab. The default model memory estimate is 1 GB and only about 600 MB is offered to machine learning; the job on the machine learning page sets
analysis_limits.model_memory_limitto 20 MB. -
No recovery messages. A rule only sends what its actions say: add an action for the
recoveredgroup, as the burn rate rule has, if the receiver should hear that the alert ended. -
The no-data rule takes the whole window. With a 5 minute window the first notification needs 5 empty minutes; shorten the window for a faster lab, at the cost of false alarms.
-
Basic licence. The connector and maintenance window requests are refused without the trial licence; check
GET _licenseshowstrial. -
A second run of the script reports conflicts. The objects have fixed ids; delete them or start from
docker compose down -v.
In the books
Shah’s Kibana 8.x: A Quick Start Guide to Data Analysis (Packt, 2024) ends its machine learning chapter by setting up an alert: it creates a rule for an anomaly detection job from the Rules page and then a connector for the rule’s action. The sequence (a rule, then a connector, then a test) is the one the script above automates, but the book shows the Kibana 8 menus only. In 9.x the Rules page is one list for Stack and Observability rule types, rules can be created from the API with fixed ids, the Dashboards API and the SLO burn rate rule exist, and maintenance windows filter by KQL; the book’s alerts are not a replacement for the five alerts built here, which also need the data views and field names of OpenTelemetry data.
Where to go next
The same exercise in Grafana is Grafana: Bookshelf End to End. For the concepts and the practices behind the numbers see Kibana: Best Practices, Alert Lifecycle, Snooze & Maintenance Windows and Actions, Frequency & Action Variables.