Blog

From 137,306 log lines to one bad replica: Debugging an error spike in Kibana

A canary nobody announced lowered the payment gateway timeout to 1.5 seconds, and 676 checkout requests failed before the logs named the line that did it.

Elasticsearch turns raw logs into structured, searchable data at ingest. Follow the collect and analyze logs tutorial to see it end-to-end. Start a free cloud trial or try Elastic on your local machine now.

The checkout service wrote 137,306 log lines in the three hours around the incident. Four steps of log analysis in Kibana got to the one line of configuration behind it.

Filtered to errors, the Discover Patterns tab collapsed 857 lines into three patterns, and only one of them was new, a payment gateway timeout. ES|QL CHANGE_POINT dated the start to 13:12, p-value 7.8e-95. Log rate analysis put all of it on one replica, a canary running version 2.14.1 while the other three ran 2.14.0. Nobody had announced it. Fourteen seconds before its first error, that replica had logged its startup configuration, and surrounding documents put it on screen: the payment gateway timeout, lowered to 1,500 ms.

The logs ship through the Elastic Distribution of OpenTelemetry (EDOT) Collector, and the same four steps work on any structured logs in Elasticsearch that record the level and the service that wrote each line.

Prerequisites

To follow along, you need:

  • Elasticsearch and Kibana 9.5 or later.

  • A Platinum or Enterprise license, or a trial.

  • Docker, to run the EDOT Collector that ships the sample log file.

  • An API key that can write to logs-checkout_api.otel-default.

You can find the companion notebook here. If you want to reproduce the example, it generates the same checkout-api logs and runs the queries from this article against them.

The problem: A checkout error spike at 13:12, and nobody deployed

The service is checkout-api, four replicas in Kubernetes writing structured JSON logs. At 13:12, the error rate on POST /api/checkout/confirm climbs from zero to about 6% and stays there. The alert fires 10 minutes later. The on-call engineer opens the service dashboard and sees exactly one thing: a line that went up.

The dashboard can’t tell you what the new errors are or whether all replicas are affected. Nor can it tell you what changed. Those answers are in the logs: 137,306 lines written in the three hours around the incident. Reading them one by one isn’t an option.

The log lines carry the fields that make the investigation possible. If your services already log through OpenTelemetry (OTel), you have the same ones:

Field

Example value

Used to answer

message (body.text in OTel documents)

Payment gateway timeout after 1500 ms for order o-93c930 (gateway=stripe-eu)

What’s new?

@timestamp

2026-09-11T18:12:09.842Z

When did it start?

log.level (severity_text)

ERROR

Which lines to analyze, in every step

k8s.pod.name, service.version

checkout-api-7f8b9c6d4-x9k2p, 2.14.1

Where is it coming from?

url.path, error.type

/api/checkout/confirm, PaymentGatewayTimeout

Where and what to fix

On the way to Elasticsearch, the EDOT Collector's file_log receiver (filelog, in older versions) parses the JSON and promotes the service and Kubernetes keys to resource attributes. The elasticsearch exporter writes OTel-native documents to logs-checkout_api.otel-default. That’s the documented path for sending any log file, with a few operators added for the JSON fields.

All times in this article and its screenshots are in UTC-5. Open Discover with the logs-* data view, and set the time range to the three hours around the incident (September 11, 2026, 11:30–14:30 Central Daylight Time, which is 16:30–19:30 UTC). Filter to the service's error lines: 

service.name : "checkout-api" and log.level : "ERROR"

Errors went from a handful per five minutes to around 50. The table under the chart holds the answers, and the next four steps surface them without scrolling through it.

How to find the root cause of an error spike with log analysis in Kibana

Every incident starts with the same four questions, and a different feature answers each one.

Feature

Question ot answers

What it gives you

Requires

Discover Patterns tab

What’s new?

Log lines grouped by message structure, with per-pattern rate charts

Classic Discover

ES|QL CHANGE_POINT

When did it start?

The bucket where the change happened, with a type and a p-value

Platinum or Enterprise

Log rate analysis

Where is it coming from?

Ranked field and value pairs explaining a rate change

Platinum or Enterprise

Surrounding documents

Why did it happen?

Lines written immediately before and after a given document

Classic Discover

What’s new? The Discover Patterns tab

Discover has a Patterns tab, next to Documents. It groups the log lines in the current query and time range by message structure, using the same categorization as the machine learning log pattern analysis. It lists each pattern with its count and a small log rate chart. Above 50,000 documents, it works on a random sample by default, so the counts on a large result set are estimates; below that size, as with the following error lines, they’re exact.

On the full three hours of checkout-api logs, the tab groups 137,306 lines into about a dozen patterns, including carts loaded, checkouts started, payments captured, health checks, and a few warnings. The new error doesn’t stand out there, because its lines share most of their words with the Payment gateway slow warnings and land in the same pattern. With the error filter from above, the 857 error lines collapse into three. Each row's log rate chart highlights that pattern's lines over all the error lines. For two of them, the highlighted slice stays thin and steady. The third didn’t exist before 13:12, and its chart shows it filling the step:

The Tokens column reads Payment gateway timeout after 1500 ms for order o gateway stripe. Numbers and identifiers are stripped, so 676 distinct log lines become one row. Click the plus icon in the Actions column to filter the Documents tab down to that pattern and read the full text of the new error.

You got your first question answered without reading a single raw log line. The new error is a payment gateway timeout after 1,500 ms, and the two error patterns that existed before the incident are still running at their old rate.

When did it start? ES|QL CHANGE_POINT

The Discover Patterns tab shows roughly when a new log pattern appeared. To get the exact minute and a number that you can put in the incident timeline, switch Discover to ES|QL with Query in ES|QL and count errors per minute:

FROM logs-checkout_api.otel-default
| STATS errors = COUNT(*) WHERE severity_text == "ERROR" BY minute = BUCKET(@timestamp, 1 minute)
| SORT minute
| CHANGE_POINT errors ON minute
| LIMIT 1000

CHANGE_POINT scans the series and adds two columns, type and pvalue, to the row where the statistics change. Discover 9.5 recognizes that output and draws the change point chart for it:

The result is step_change at 2026-09-11T18:12:00.000Z, which is 13:12 in the browser's time zone, with a p-value of 7.8e-95. Errors per minute went from about one to about 10, and the timestamp is now a fact rather than an estimate from a chart.

The filtered aggregation, COUNT(*) WHERE severity_text == "ERROR" over all log lines, is deliberate, and so is the LIMIT 1000. It matches the number of values that CHANGE_POINT reads and prevents Discover from adding its default limit with a warning. It keeps a row for every minute, including minutes with zero errors. Filtering to errors first with WHERE would drop the quiet minutes from the series, and the change point detector would see gaps instead of a baseline.

Where is it coming from? Log rate analysis

Log rate analysis compares the documents in a deviation window against a baseline window and ranks the field and value pairs that explain the difference. The new errors could be on every replica or on just one, and that difference decides the fix.

To run it:

  1. Open Machine Learning. Then open AIOps Labs and Log rate analysis (or enter Log rate analysis in the global search field)

  2. Choose the logs-* data view

  3. Use the same query that isolates the errors:

service.name : "checkout-api" and log.level : "ERROR"

The histogram shows the step at 13:12. Click Run analysis; log rate analysis places the baseline and deviation brushes around the step on its own and ranks the field values. On OTel-native data, each value shows up more than once; for example, as k8s.pod.name, as resource.attributes.k8s.pod.name, and as the Elastic Common Schema (ECS) alias kubernetes.pod.name. 

To fix this:

  1. Open Fields

  2. Search for attributes. and click Deselect all 

  3. Search for kubernetes. and click Deselect all

  4. Click Apply. (The Gotchas and troubleshooting advice section in our article explains why.) 

The table now has one row per field:

Every significant value points at the same place. k8s.pod.name is checkout-api-7f8b9c6d4-x9k2p, a pod name that didn’t exist in the baseline. service.version is 2.14.1, while the other three replicas run 2.14.0. Also, url.path is /api/checkout/confirm, and error.type is PaymentGatewayTimeout, each rated High impact with a log rate change from zero in the baseline. Nobody on the incident call deployed anything, but a canary of the next version went out to one replica, and the logs name it.

Why did it happen? Surrounding documents

The errors come from a single replica running a new version. The last question is what the new version does differently, and the answer is usually in the first few lines that a process writes when it starts.

Back in Discover:

  1. Click Switch to Classic (surrounding documents aren’t available in ES|QL mode) 

  2. Add a filter on the canary pod, and then pin it 

  3. Sort by time ascending

  4. Expand the first timeout error

  5. In the document details, choose View surrounding documents

Discover opens the lines written immediately before and after that error, with the newest first. The pinned filter keeps the view on the same pod. The query bar isn’t carried over, so lines of every level show up and the startup log is right there:

About 14 seconds before the first timeout, the pod logged Loaded configuration: payment_gateway.timeout_ms=1500, payment_gateway.retries=3, feature.fast_capture=true. Version 2.14.1 lowered the payment gateway timeout to 1.5 seconds. The gateway's slow tail, visible as Payment gateway slow warnings above 1,500 ms on every replica in the baseline, now fails instead of waiting. The view reports only seven older documents for this pod, because the pod had written seven lines before its first error.

The fix follows from the evidence; roll the canary back or raise the timeout, and then look at the gateway's real latency distribution before shipping 2.14.1 again.

Confirm the root cause with one query

Before rolling anything back, one query confirms that the four findings agree, breaking down the errors by pod, version, and type over the incident window:

FROM logs-checkout_api.otel-default
| WHERE severity_text == "ERROR"
| STATS errors = COUNT(*), first_seen = MIN(@timestamp) BY k8s.pod.name, service.version, error.type
| SORT errors DESC
| LIMIT 20

All 676 timeouts sit on the canary, and its first one is at 13:12:09. The other replicas show only the two error types that were there before the incident, at the same low rate as before.

Troubleshooting log analysis in Kibana

OTel logs put the message in body.text. The index template for OTel-native data streams (logs-otel@mappings) defines message as an alias of body.text and log.level as an alias of severity_text, so the Patterns tab and the Kibana Query Language (KQL) above work unchanged on OTel-native data. Resource and log attributes, such as k8s.pod.name and url.path, are queryable by their short names, too. 

Exception details from instrumented applications land in attributes, such as exception.message, rather than in the body, and log rate analysis only runs pattern analysis on message and error.message. If your errors are exceptions, add error.type or exception.type to the field selection rather than relying on the message pattern.

  • Give CHANGE_POINT a complete series. The command needs at least 22 values and ignores anything after the first 1,000, so pick a bucket size that fits your time range: one minute for a few hours, five minutes for a day. Keep quiet buckets in the series with a filtered aggregation, as shown above, or the detector sees gaps rather than a baseline. CHANGE_POINT has been generally available since 9.2 and requires a Platinum or Enterprise license, as does log rate analysis.

  • Log rate analysis needs a rate that changed. It looks for a change in the rate of the documents that it analyzes. The total log volume of the service didn’t move at 13:12; only the error volume did. Query for the error lines first. It also needs a healthy baseline window, so if the problem started before the beginning of your time range, widen the range until the brushes cover both.

  • Log rate analysis preselects fields. When the documents carry an ecs.version field, the analysis starts from a curated list of ECS fields, and that list leaves out k8s.pod.name and url.path. OTel-native documents have no ecs.version, so it takes the first 100 keyword fields in alphabetical order instead: every OTel field under its short name, its attributes. or resource.attributes. path, and any ECS alias, which is why each value appeared three times in this incident. Either way, open Fields before you read the table, switch on the fields that identify where your service runs, switch off the duplicates, and click Apply to rerun. Only keyword and IP fields are candidates, plus the message text field for patterns, so numeric fields, such as http.response.status_code, never are.

  • Patterns need a message field that reads like a sentence. Before it categorizes, Discover checks a sample of the field's values and warns that the field is "possibly not suitable for pattern analysis" when the values have too few tokens, too many nulls, or too many tokens in total. The last case is what happens when a whole JSON document or a stack trace is stored as the message. Parse those fields first, at the Collector or in Streams after ingestion, and keep the human-readable sentence as the message.

  • The "where" step is only as good as your metadata. Pod name and service version were fields on every line in this incident. If your logs don’t carry them, add them at ingest time with the Collector's resource detection and Kubernetes attributes processors, before the next incident rather than during it.

  • Time zones. The Collector parsed the timestamps in UTC; Kibana shows them in the browser's time zone. When you put a change point into an incident timeline, note which one you mean.

Key takeaways for log analysis in Kibana

We got answers to four questions with four features and nothing but the service's logs. The Patterns tab, filtered to errors, turned 857 error lines into three patterns and exposed the one that was new. ES|QL CHANGE_POINT put a minute and a p-value on the start of the incident. Log rate analysis named the canary replica and its version without anyone guessing which field to group by. And surrounding documents showed the configuration line that explained it.

Our key takeaways here include:

  • Start investigations in the Patterns tab, filtered to the lines whose rate changed, not in the raw log list. New behavior shows up as a new pattern with a log rate chart that starts at the incident.

  • Count errors per minute over all logs with a filtered COUNT(*) WHERE, and then run CHANGE_POINT to get an exact start time with a p-value.

  • Run log rate analysis on the documents whose rate changed, and check its field selection before you read the ranking.

  • Use surrounding documents on the first error from the affected instance; startup and configuration lines are usually a few seconds away.

  • Structured fields, such as k8s.pod.name and service.version, are what make the where step a click instead of a hunt. Add them at the EDOT Collector.

Documentation for the features used here

Following is the documentation for each feature used in this article:

How helpful was this content?

Related Content

Your ingest path lives in someone's head; Elastic Streams Map draws it

Your ingest path lives in someone's head; Elastic Streams Map draws it

Patri Pascual
Meet the new Elastic Streams: Managed data pipelines for telemetry

Meet the new Elastic Streams: Managed data pipelines for telemetry

Marcin Stożek

Elastic Observability Labs Newsletter