Search and Visualise Logs in Kibana, Hands-On
A customer says checkout failed a few minutes ago. In lesson 17 you proved that shop-demo's lines reach Elasticsearch, about four a second, but a curl count cannot tell you which ones failed or why. Kibana can. This lesson shows you how to search logs in Kibana by field, narrow them down to one failing request, chart the errors with Lens and save the result.
Create a data view for shop-logs-*
Kibana does not search Elasticsearch until you tell it where to look. A data view is that instruction: an index pattern such as shop-logs-*, where * matches any text and so every daily index, plus the field that holds each document's time. Kibana's time picker and histograms use that field, so pick @timestamp, which lesson 17's date filter set from the app's own clock.
Find the Data Views page with the search field at the top of Kibana, or in the main menu under Stack Management. Then:
- Select Create data view.
- Type
shop-logsas the Name andshop-logs-*as the Index pattern. The right side lists the matching indices, such asshop-logs-2026.11.27. - Under Timestamp field, choose
@timestamp. - Select Save data view to Kibana.
If no index matches, Logstash has not written one yet: run the _cat/indices check from lesson 17 before you go on.
Discover: time picker, fields and KQL
Open Discover from the main menu and pick shop-logs in the data view menu. Kibana 9.5 opens Discover in classic mode, which searches a data view. If the query bar shows a query starting with FROM, you are in ES|QL mode, Elastic's piped query language: switch back to classic mode from the top menu.
The time picker, top right, starts at Last 15 minutes. Discover searches only documents whose @timestamp falls inside it, so an empty page usually means the window misses the data. Open it to choose a wider range, such as Last 1 hour.
The field list on the left shows every field in the documents, each with an icon for its type. Select route to see its top values in a sample of the matching documents: /products first, then /checkout and /report. There is no /, because lesson 17's pipeline drops successful visits to it.
The query bar speaks KQL, the Kibana Query Language. field: value keeps documents whose field matches, quotes make the value one exact phrase, and, or and not combine conditions, and >= compares numbers. Try these one at a time, pressing Enter after each:
level: "error"
level: "error" and route: "/checkout"
duration_ms >= 500 and not route: "/report"
In this lab the first two usually return the same documents, because almost every error line is a failed payment. The third finds the slow payments, about one checkout in twenty. The histogram redraws for each query, so you see when the matches happened.
Each text field such as route also has a route.keyword twin: the text field is split into words for search, while the keyword keeps the exact value for grouping and counting. KQL searches route; charts group by route.keyword.
Narrowing down to one error
A filter is a condition kept outside the query text, shown as a pill under the query bar. Add one with Add filter, the plus icon next to the query bar: pick route as the field, is as the operator and /checkout as the value, then select Add filter. Select the pill later to Exclude results, which inverts it, or to Temporarily disable it without deleting it.
By default the table has two columns, @timestamp and Summary, which packs every field into one cell. Select Add field as column, the + next to route, status and message in the field list, so the table reads like a spreadsheet.
Now open one error. The expand icon at the start of a row, whose tooltip in 9.5 reads Toggle dialog with details, opens the Document flyout, a panel that slides in beside the table. Its Table tab lists every field and its value, such as message checkout failed, error payment provider timed out and status 500, plus order_id, items and duration_ms; JSON shows the stored document.
In the flyout, View surrounding documents shows the five lines just before and after this one in time, with buttons to load more. Only pinned filters, the ones you pin to every Kibana app from the pill's menu, stay active there, so you see every route, not just errors. Ordinary /products and /checkout lines around the failure tell you it was one payment, not an outage.
Look again at an expanded error: it has an order_id but no trace_id. This lab runs the plain shop-demo from lesson 2, which has no tracing. The instrumented shop-demo-otel from lesson 14 adds trace_id and span_id to each log line of a traced request. In lesson 19, that shared ID links a request's log lines to its trace in Jaeger.
Save the search, chart it with Lens, build a dashboard
Back in Discover, with level: "error" and route: "/checkout" and your columns, select Save and name it Checkout errors. Kibana 9.5 calls a saved search a Discover session: it keeps the query, filters and columns, and the time range only if you switch on Store time with Discover session. You should see Discover session 'Checkout errors' was saved.
Lens is Kibana's drag-and-drop chart editor. Open Dashboards, select Create a dashboard, then Create visualization. Lens opens on shop-logs, your only data view.
- Errors over time. Drag
@timestamponto the empty workspace. Lens draws a line chart of Count of records per time interval. Typelevel: "error"in Lens's own query bar, then select Save and return. - Top routes by count. Select Add in the dashboard's top menu, then Visualization, and drag
route.keywordonto the workspace. Lens draws a bar chart of Top values ofroute.keyword, one bar per route, ranked by Count of records. Save and return. - The saved search. Select Add again, open the From library tab and pick the Discover session
Checkout errors: the panel shows the same table as Discover.
Select Save, type Shop logs as the Title and save. Every panel follows the dashboard's time picker, so one change of range updates them all. Kibana keeps data views, Discover sessions and dashboards in its own indices in Elasticsearch, so docker compose down keeps them and down -v deletes them.
Check yourself
Discover shows no results for level: "error", yet _cat/indices shows the document count growing. What do you check first?
The time picker. Discover searches only documents whose @timestamp is inside the window, and errors are rare, so a short window can hold none. Widen it before you doubt the pipeline.
Why does Lens offer route.keyword for top routes instead of route?
Counting needs exact values. route is a text field split into words for search, while route.keyword keeps the whole value as one term that can be grouped.
You open an error's surrounding documents and see only normal /products and /checkout lines around it. What does that suggest?
That the failure was a single request, not an outage: the app kept serving before and after it. Many errors in a row would point to a wider problem.