Modern Spring Boot applications rarely fail in simple ways.
A request may start at an API gateway, move through several microservices, wait for a Kafka message, query a database, call an external API, and finally return a response to the customer.
When that request suddenly takes 5 seconds instead of 200 milliseconds, checking whether the application is "up" is not enough. You need to understand what happened inside the system.
This is where observability becomes critical.
For senior Java and Spring Boot engineers, observability is no longer just a monitoring topic. It is an important part of designing, operating, and troubleshooting production microservices.
In this article, we will cover 40 senior-level Spring Boot observability interview questions and answers, including Micrometer, OpenTelemetry, Prometheus, Grafana, distributed tracing, structured logging, Kubernetes, Kafka, JVM monitoring, SLIs, SLOs, and production troubleshooting.
Observability is the ability to understand the internal state and behavior of an application by analyzing the data it produces.
In a production Spring Boot system, observability helps answer questions such as:
A good observability setup combines metrics, logs, and distributed traces to provide a complete picture of the application.
Observability is the ability to understand what is happening inside a system by examining the telemetry data generated by that system.
For a Spring Boot microservice, this typically means collecting metrics, logs, and traces and using them together to investigate application behavior.
For example, if an API becomes slow, metrics may show increased latency, traces may identify a slow database call, and logs may provide the exact error or business context.
Monitoring generally focuses on known conditions and predefined signals.
For example:
"Alert me when CPU usage exceeds 80%."
Observability goes further. It helps engineers investigate unknown problems and understand why something happened.
Monitoring might tell you that latency increased. Observability helps you determine whether the increase was caused by a database, another microservice, Kafka, an external API, or resource exhaustion.
The traditional three pillars are:
Modern observability platforms often correlate all three so engineers can move from a high-level metric to a trace and then to the relevant logs.
Metrics are best for understanding system health and trends.
Examples include request rate, error rate, CPU usage, memory usage, and API latency.
Logs provide detailed event information.
Examples include exceptions, validation failures, authentication failures, and business events.
Traces show how a request travels through a distributed system.
For example:
API Gateway → Order Service → Payment Service → Database
When debugging microservices, these three signals complement each other rather than replacing one another.
Micrometer is an instrumentation library that provides a vendor-neutral metrics API for JVM applications.
It allows applications to record metrics without tightly coupling application code to a specific monitoring backend.
Micrometer can work with monitoring systems such as Prometheus and many other monitoring platforms.
Spring Boot integrates strongly with Micrometer through Spring Boot Actuator.
This allows applications to expose useful application and JVM metrics with relatively little configuration.
Typical metrics include:
OpenTelemetry is an open-source observability framework for generating, collecting, and exporting telemetry data.
It supports signals such as:
One of its important benefits is vendor neutrality. Applications can generate telemetry without being tightly coupled to a particular observability vendor.
Micrometer has traditionally focused heavily on application metrics and provides a metrics abstraction commonly used in the Spring ecosystem.
OpenTelemetry provides a broader observability framework covering traces, metrics, and logs.
In a Spring Boot application, they can complement each other. Micrometer can be used for application metrics while OpenTelemetry provides broader telemetry and distributed tracing capabilities.
Distributed tracing tracks a request as it moves across multiple services.
Consider an e-commerce request:
Client → API Gateway → Order Service → Payment Service → Inventory Service → Database
A distributed trace allows an engineer to see how much time was spent in each component.
This is particularly valuable when the overall request is slow but each individual service appears healthy when viewed independently.
A Trace ID uniquely identifies a complete distributed request.
The same Trace ID can be propagated across multiple services participating in that request.
This allows engineers to follow one request across the entire microservice architecture.
A span represents a single unit of work within a trace.
For example, a trace could contain spans for:
Each span contains information such as start time, duration, operation name, attributes, and relationships to other spans.
A Trace ID identifies the complete request journey.
A Span ID identifies one specific operation within that trace.
Think of the Trace ID as identifying the entire journey and the Span ID as identifying one stop along that journey.
Trace context is normally propagated through request metadata such as HTTP headers.
Modern distributed tracing commonly uses the W3C Trace Context standard.
The calling service propagates the trace context, and the receiving service extracts it and creates the next span as part of the same trace.
This is what allows multiple independent services to appear as one connected request in a tracing system.
Spring Boot applications can integrate with OpenTelemetry using supported instrumentation libraries, agents, SDKs, or Spring ecosystem integrations.
The application can generate telemetry and export it to an OpenTelemetry Collector or another compatible backend.
A typical architecture is:
Spring Boot Application → OpenTelemetry → Collector → Observability Backend
Prometheus is a time-series monitoring system that commonly collects metrics using a pull model.
It periodically requests metrics from configured targets and stores the resulting time-series data.
Spring Boot applications can expose metrics through an endpoint that Prometheus can scrape.
In the pull model, Prometheus actively requests metrics from monitored applications.
For example:
Prometheus → HTTP request → Spring Boot metrics endpoint
The application exposes metrics, while Prometheus decides when to collect them.
This makes service discovery and centralized metric collection easier to manage in many environments.
Grafana is primarily used for visualizing and analyzing observability data.
Teams can create dashboards showing:
Grafana can connect to Prometheus and many other data sources.
Prometheus and Grafana have different responsibilities.
Prometheus primarily collects and stores time-series metrics and provides a query language for analyzing them.
Grafana primarily visualizes data and creates dashboards and alerts from supported data sources.
A common architecture is:
Spring Boot → Micrometer → Prometheus → Grafana
Important JVM metrics include:
For production systems, memory usage should be analyzed together with garbage collection behavior and application latency.
Useful Spring Boot metrics include:
The exact metrics should depend on the application's architecture and business requirements.
API latency can be measured using HTTP server request metrics.
Instead of looking only at average response time, production systems should examine latency distributions and percentiles such as p50, p95, and p99.
This gives a much better understanding of how different groups of users are experiencing the application.
Error rates can be calculated by comparing failed requests with total requests.
For example:
Error Rate = Failed Requests / Total Requests × 100
It is often useful to break errors down by HTTP status code, endpoint, service, region, or other relevant dimensions.
Percentiles describe the distribution of request latency.
p95 means approximately 95% of requests completed at or below that latency, while the slowest 5% were above it.
p99 means approximately 99% of requests completed at or below that latency, while the slowest 1% were above it.
These measurements are especially useful for identifying long-tail latency problems.
Average latency can hide slow requests.
Imagine 99 requests complete in 100 milliseconds and one request takes 10 seconds.
The average may still look acceptable while one user experienced a very slow request.
Percentiles such as p95 and p99 expose these tail-latency problems more effectively.
Start with the trace for a slow request and inspect the individual spans.
Look for the span consuming the largest amount of time.
For example:
Order Service: 100 ms
Payment Service: 150 ms
Inventory Service: 3.8 seconds
The trace immediately points the investigation toward the Inventory Service.
You can then investigate its database queries, external dependencies, thread pools, CPU, and other metrics.
Trace and span identifiers can be included in application logs.
For example:
trace_id=abc123 span_id=xyz789 payment processing started
An engineer can then search centralized logs using the Trace ID and see all relevant log entries associated with that request.
This creates a powerful debugging flow:
Metric → Trace → Log
Structured logging stores log information in a machine-readable format, commonly JSON.
Instead of:
Payment failed for order 123
A structured log might contain fields such as:
This makes searching, filtering, and analyzing logs much easier.
In a microservice environment, logs should generally be collected centrally rather than relying on engineers to inspect individual application servers.
A common architecture is:
Spring Boot → Log Collector → Centralized Log Platform → Search/Dashboard
Depending on the environment, teams may use solutions based on Elasticsearch, OpenSearch, Loki, or other centralized logging platforms.
ELK traditionally refers to Elasticsearch, Logstash, and Kibana and is commonly associated with centralized log collection, processing, storage, and visualization.
OpenTelemetry is a broader observability framework designed to generate and collect telemetry such as traces, metrics, and logs.
They are not necessarily direct replacements for each other. An organization can use OpenTelemetry for telemetry collection and Elasticsearch-based systems as one of the storage or analysis backends.
Custom metrics are useful when standard framework metrics do not capture an important business or application behavior.
For example, you may want to measure the number of orders processed.
Counter orderCounter = Counter.builder("orders.processed")
.description("Number of processed orders")
.register(meterRegistry);
orderCounter.increment();The metric can then be exported to a supported monitoring backend.
Custom metrics should be designed carefully to avoid high-cardinality labels.
Kafka consumer lag represents how far a consumer is behind the latest available messages in a partition.
Increasing lag can indicate:
Kafka lag should therefore be monitored alongside consumer throughput, processing latency, errors, and resource utilization.
For applications using a connection pool such as HikariCP, important metrics include:
If active connections remain near the pool limit and requests are waiting for connections, the database connection pool can become a significant application bottleneck.
A memory leak often appears as continuously increasing memory usage combined with garbage collection pressure.
Start by observing:
If memory does not return to a normal baseline after garbage collection, further investigation using heap dumps and profiling tools may be necessary.
First determine whether the CPU increase is isolated to the JVM or affects the underlying container or node.
Then correlate CPU metrics with:
A CPU spike after a deployment could indicate a code regression, inefficient algorithm, excessive serialization, or unexpected traffic behavior.
Observability in Kubernetes should cover both application-level and infrastructure-level signals.
At the application level, monitor:
At the Kubernetes level, monitor:
The important point is to correlate application and infrastructure signals rather than monitoring them independently.
Not every metric needs an alert.
A useful alert should represent a condition that requires human attention.
Good alerts are generally:
For example, alerting because CPU briefly reached 80% may generate noise. An alert based on sustained high latency and increasing error rates may be much more meaningful.
SLI stands for Service Level Indicator.
It is a measurable indicator of service performance or reliability.
Examples include:
SLO stands for Service Level Objective.
It defines the target level of service performance.
For example:
"99.9% of successful API requests should complete within the defined latency target over a rolling period."
SLOs help teams decide what level of reliability they are trying to achieve.
SLA stands for Service Level Agreement.
An SLA is typically a formal commitment between a service provider and a customer.
For example, a business may contractually promise a certain level of service availability.
A simple way to remember the difference is:
SLI = What we measure
SLO = What we target
SLA = What we formally commit to
A production architecture could look like this:
Users → API Gateway → Spring Boot Microservices → Kafka/Databases/External APIs
Telemetry from the services can then flow through observability components:
Spring Boot → Micrometer / OpenTelemetry → Collectors → Metrics, Logs and Traces Backends → Dashboards and Alerts
A practical architecture should provide:
The architecture should also consider telemetry volume, storage costs, retention, security, sensitive-data handling, and high-cardinality dimensions.
Question:
Your production Spring Boot application suddenly shows high latency. How would you use metrics, logs, and distributed traces to identify the root cause?
Answer:
I would not immediately start looking at application logs. I would first establish the scope and impact of the problem using metrics.
I would check:
This helps determine whether the problem is application-wide or isolated to a particular endpoint or dependency.
I would take a slow request and inspect its trace.
For example:
API Gateway: 50 ms
Order Service: 100 ms
Payment Service: 4 seconds
The trace immediately suggests that Payment Service deserves further investigation.
Once the slow service is identified, I would examine its spans and determine whether the delay is caused by:
I would use the Trace ID from the slow request to search centralized logs.
This could reveal timeout messages, exceptions, retries, connection failures, or other application-level information that explains the behavior.
Finally, I would correlate the incident with recent deployments, configuration changes, traffic increases, infrastructure changes, or dependency failures.
The overall troubleshooting flow would be:
Metrics → Identify the problem → Trace → Identify the bottleneck → Logs → Find the root cause → Validate the fix
At a junior level, developers often focus on whether the code works.
At a senior level, the question becomes much broader:
How will we know when the system stops working correctly in production?
A production-ready Spring Boot service needs more than REST APIs and business logic. It needs visibility into performance, failures, dependencies, infrastructure, and user impact.
That is why observability should be considered part of application architecture rather than something added after deployment.
Micrometer, OpenTelemetry, Prometheus, Grafana, centralized logging, and distributed tracing are powerful tools, but tools alone do not create observability.
The real value comes from connecting these signals and using them to answer production questions quickly.
When an application becomes slow, the goal should not be to search thousands of log lines blindly. A well-designed observability platform should help an engineering team move from symptom → evidence → bottleneck → root cause.
If you are designing or modernizing a Java/Spring Boot microservices platform, observability should be considered from the beginning of the architecture.
Looking to build scalable, production-ready Java and Spring Boot applications? Explore more practical Java, Spring Boot, microservices, AWS, and backend engineering content from LogicBrace.
There is no single best tool. A common approach is to use Micrometer for metrics, OpenTelemetry for broader telemetry and tracing, Prometheus for metrics storage and querying, Grafana for visualization, and a centralized logging platform for logs.
They solve overlapping but different problems. Micrometer is widely used for metrics instrumentation in the Spring ecosystem, while OpenTelemetry provides a broader framework for metrics, traces, and logs. They can be used together.
Average latency can hide slow requests. p95 and p99 expose tail latency and provide a better understanding of how the slowest portion of users are experiencing the application.
At minimum, consider request rate, error rate, latency, JVM memory, garbage collection, CPU, threads, connection pools, dependencies, and relevant business metrics. Distributed tracing and structured logging are also valuable for troubleshooting.
An SLI is the measurement, an SLO is the target for that measurement, and an SLA is a formal service commitment, typically made to customers or users.
0 Comments