Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Describe how logs from Spring Boot services in Kubernetes reach Elasticsearch and Kibana in an ELK or EFK stack, and why structured JSON logs matter.

Spring Boot services in Kubernetes write logs to stdout, the container runtime stores them in files on the node, and a node agent such as Filebeat, Fluent Bit or the OpenTelemetry collector tails those files and ships the events to Logstash or straight to Elasticsearch. Logstash or Elasticsearch ingest pipelines parse and enrich each event with the pod, namespace and service, Elasticsearch indexes it, and Kibana gives us search, dashboards and alerts. JSON logs matter because they arrive already split into fields, so there is no fragile grok parsing, multi-line stack traces stay in one event, and fields like traceId are searchable.

Why this question is asked

Centralised logging is one of the first things a team needs when it moves services to Kubernetes, because pods come and go and their logs disappear with them. ELK stands for Elasticsearch, Logstash and Kibana; EFK replaces Logstash with Fluentd or Fluent Bit. Interviewers ask about it to check that we understand the path a log line takes and where it typically breaks, and why the format the application writes makes such a difference. In this answer, we will recap the components, follow one log line from a Spring Boot pod into Kibana, look at what parsing and enrichment do, and then see what plain text costs us compared with structured JSON.

1A Quick Recap of the Components

Elasticsearch is a distributed search engine that stores log events as JSON documents in indices and makes every field searchable. Logstash is a processing server that receives events, transforms them with filters and sends them on. Kibana is the web interface for searching, building dashboards and defining alerts on the data in Elasticsearch.

The shipper is the piece that collects logs where they are written. Filebeat is Elastic's lightweight shipper, Fluent Bit is a small, fast agent from the Fluentd project, and the OpenTelemetry collector can also read log files and send them on. In Kubernetes the shipper runs as a DaemonSet, meaning one copy on every node.

2Following One Log Line From Pod to Kibana

A Spring Boot application in a container should log to stdout, not to files inside the container. That is the Kubernetes convention, and it is what Boot does by default. The container runtime captures stdout and writes it to a file on the node, under /var/log/containers, with a timestamp and stream prefix per line. The node's shipper tails those files, which is why it needs to run on every node.

From there the shipper sends events either to Logstash, when we need heavier processing or several destinations, or directly to Elasticsearch, where an ingest pipeline can do lighter processing. Elasticsearch writes the events into an index or a data stream, typically one per day or rolled over by size, and Kibana queries it.

Step throughPath of a log line in EFK or ELK
  1. Spring Boot pod writes to stdoutOne JSON object per line
  2. Container runtimeWrites /var/log/containers/<pod>_<ns>_<container>.log
  3. Node agent (DaemonSet)Filebeat, Fluent Bit or OTel collector tails the file
  4. Logstash or ingest pipelineParse, add pod, namespace, service, route
  5. ElasticsearchIndex or data stream, fields searchable
  6. KibanaSearch, dashboards, alerts

6 steps in order. Play them, or step through them one at a time.

Each step adds something; parsing is where plain text causes trouble.

3Parsing, Enrichment and Routing

Parsing turns the raw line into fields. Enrichment adds context the application does not know: the pod name, namespace, node, container image and labels, which the shipper reads from the Kubernetes API. With these, we can filter Kibana by namespace or by the app label, or find every log line from pods of one deployment. Routing decides where an event goes, for example audit events to a separate, protected index, or debug logs of one team to an index with shorter retention.

When the application writes plain text, parsing needs grok, a pattern language based on regular expressions. Here is a typical Boot line and the grok that tries to split it.

Java
# Plain text from Spring Boot's default pattern
2026-11-06T10:15:02.114Z INFO 1 --- [orders] [nio-8080-exec-3] c.e.orders.OrderController : order placed id=A-1093
# Logstash filter
filter {
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:ts}\s+%{LOGLEVEL:level} %{NUMBER:pid} --- \[%{DATA:app}\] \[%{DATA:thread}\] %{JAVACLASS:logger}\s*: %{GREEDYDATA:msg}" }
}
}
# -> works until someone changes the pattern, adds the correlation ids, or a message contains odd characters

Notice how tightly the pattern is bound to the exact layout. A Boot upgrade that adds a field, such as the trace and span ids, or a team that customises its pattern, breaks parsing, and the events either fail or land with everything in one message field.

4The Multi-Line Stack Trace Problem

A Java exception in plain text is not one line but dozens: the message, then each at line, then caused by sections. The runtime writes each line separately, and the shipper sees each as its own event unless we configure multi-line rules that join lines starting with whitespace or at. Those rules are fragile too, and when they fail, a single exception becomes 60 separate documents in Kibana, none of which shows the whole story.

There is a second, quieter issue: container runtimes split very long lines into parts, so a huge log message can arrive in pieces that the shipper must join. Most agents handle this, but it is another place where plain text logging is brittle.

5Why Structured JSON Logs Matter

If each event is written as one JSON object on one line, the shipper only needs to decode JSON, which every agent does reliably. Fields arrive with their names, the stack trace is a single string field inside the event, and nothing depends on a pattern. Spring Boot 3.4 and later can write this directly with logging.structured.format.console, for example ecs, which matches the field names Elasticsearch and Kibana expect; check the exact options for your version. Older versions can use the logstash-logback-encoder.

Properties
# application.properties
logging.structured.format.console=ecs
# One event, shortened:
# {"@timestamp":"2026-11-06T10:15:02.114Z","log.level":"ERROR","service.name":"orders",
# "message":"payment failed","traceId":"4bf92f35...","error.stack_trace":"java.lang.IllegalStateException: ...\n\tat ..."}
# Filebeat input for containers, decoding JSON instead of grok
# - type: filestream
# parsers: [ { container: {} }, { ndjson: { target: "" } } ]

The result is that fields like traceId and service.name are searchable from day one, so we can go from a trace to its log lines with one query. Parsing configuration shrinks to almost nothing, and a Boot upgrade no longer risks silently breaking ingestion.

6Follow-up questions

Should Spring Boot send logs directly to Elasticsearch with an appender?

Usually not. A direct appender couples the application to the logging backend, and when Elasticsearch is slow the application may block or lose logs. Writing to stdout and letting a node agent ship them keeps the application simple and lets the platform change the pipeline without redeploying services.

When is Logstash worth running instead of shipping straight to Elasticsearch?

When we need heavy transformations, several destinations, buffering with a persistent queue or a dead letter queue for failed events. For simple JSON logs with Kubernetes metadata, a shipper plus an Elasticsearch ingest pipeline is often enough and has fewer parts.

What is the difference between Fluentd and Fluent Bit?

Both come from the same project. Fluent Bit is written in C, uses very little memory and is designed to run on every node. Fluentd is written in Ruby with a large plugin ecosystem and is often used as an aggregator. A common EFK setup runs Fluent Bit on nodes, sometimes forwarding to Fluentd.

7Conclusion

In this answer, we followed a log line from a Spring Boot pod to Kibana. The application writes to stdout, the container runtime stores it on the node, a node agent such as Filebeat, Fluent Bit or the OpenTelemetry collector ships it, Logstash or an ingest pipeline parses, enriches with pod, namespace and service and routes it, Elasticsearch indexes it and Kibana searches it. Plain text needs fragile grok patterns and breaks multi-line stack traces into many events, while structured JSON, built into Spring Boot 3.4 and later, arrives as fields and keeps traceId searchable.

What to say in the interviewAbout 80 seconds aloud

Open with

In Kubernetes, the Spring Boot app just logs to stdout. The container runtime writes that to files on the node under /var/log/containers, and a node agent running as a DaemonSet, Filebeat, Fluent Bit or the OpenTelemetry collector, tails those files and ships the events, either to Logstash or directly to Elasticsearch.

Then, if they want more

On the way, Logstash or an Elasticsearch ingest pipeline parses the line into fields, enriches it with Kubernetes metadata like pod, namespace and app labels, and routes it, for example audit logs to a protected index. Elasticsearch indexes the events, usually in data streams that roll over, and Kibana gives us search, dashboards and alerts. The format matters a lot.

With plain text, parsing depends on grok patterns tied to the exact log layout, so a Boot upgrade or a custom pattern breaks them, and Java stack traces arrive as dozens of separate lines unless multi-line rules work perfectly.

With JSON, one object per line, the agent only decodes JSON, the stack trace is one field, and fields like traceId and service.name are searchable immediately, which is what links logs to traces. Since Boot 3.4 that's built in with logging.structured.format.console, for example ecs, and on older versions I'd use the logstash Logback encoder.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3.4
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Describe how logs from Spring Boot services in Kubernetes reach Elasticsearch and Kibana...": https://scrivio-interview-library.netlify.app/spring-boot/observability/e2fa89b89f/