Observability & Actuator
Running Spring in production with visibility: Actuator endpoints and health, Micrometer metrics, the Observation API and tracing, and logging. Interviewers ask because knowing your service is broken before your users do is part of the job.
part ofSpring Frameworkoverview, primer and where to startread it →on this pageshowhide
explore
- Actuator Endpoints & Exposure42 questions
- Built-in Endpoints Catalog6 questions
- loggers Endpoint5 questions
- threaddump, heapdump & httpexchanges5 questions
- Endpoint Exposure over Web & JMX5 questions
- Writing Custom Endpoints6 questions
- Securing Actuator Endpoints5 questions
- auditevents Endpoint & AuditEventRepository5 questions
- info Endpoint & InfoContributor5 questions
- Health Indicators & Probes26 questions
- HealthIndicator & HealthContributor5 questions
- Built-in Health Indicators6 questions
- Health Status, Aggregation & show-details5 questions
- Health Groups5 questions
- Kubernetes Liveness & Readiness Probes5 questions
- Micrometer Metrics & Export35 questions
- MeterRegistry & Registry-per-Backend5 questions
- Counter & Gauge4 questions
- Timer & DistributionSummary5 questions
- Tags, Common Tags & Meter Filters5 questions
- @Timed & @Counted5 questions
- Export to Prometheus & OTLP5 questions
- Auto-configured Meters & MeterBinders6 questions
- Observation API & Distributed Tracing25 questions
- Observation API & ObservationRegistry5 questions
- ObservationHandler & Predicates5 questions
- Micrometer Tracing Bridges (OTel/Brave)5 questions
- Span Propagation & Baggage5 questions
- Trace Sampling5 questions
- Application Logging20 questions
- Logback & Log4j2 Configuration5 questions
- Log Levels & Groups5 questions
- Structured / JSON Logging5 questions
- Correlation IDs & Trace-ID in Logs5 questions
questions
148 · 5 sectionsWhat is the Actuator discovery index at /actuator, and how do you find out which endpoints your running app actually exposes?
basics
~10 sGET /actuator returns a JSON document with a _links section. Each entry maps an endpoint id (like health, metrics, beans) to its URL. It's the menu of endpoints currently exposed over the web.
What do /actuator/health and /actuator/info return, and where does their content come from?
basics
~20 s/actuator/health reports whether the app and its dependencies are healthy, returning a status like UP or DOWN. /actuator/info returns arbitrary descriptive info (build version, git commit) contributed by the app; it is empty unless you configure contributors.
How do you create a basic custom Actuator endpoint in Spring Boot, and what must you do before it becomes reachable over HTTP?
basics
~10 sMake a Spring bean annotated with @Endpoint(id="...") and give it a method annotated @ReadOperation. Then expose it via management.endpoints.web.exposure.include so it appears under /actuator/<id>.
Which Actuator endpoints are reachable over HTTP by default in a Spring Boot app, and how do you expose additional ones?
basics
~10 sBy default only the health endpoint is exposed over the web. To expose more, list their IDs (or * for all) in management.endpoints.web.exposure.include, e.g. include=health,info,metrics.
What is the Actuator /actuator/info endpoint and where does its content come from?
basics
~10 sGET /actuator/info returns arbitrary application info as JSON. Spring Boot builds the response by collecting every InfoContributor bean; each one adds details like build version, git commit, or Java/OS info.
What are Spring Boot's built-in health indicators, and which ones does Actuator auto-register out of the box?
basics
~10 sBuilt-in health indicators are checks Actuator adds automatically to the /actuator/health endpoint. Common ones: PingHealthIndicator (always up), DiskSpaceHealthIndicator (free disk), DataSourceHealthIndicator (database), and RedisHealthIndicator when those libraries are present.
What is an Actuator health group in Spring Boot, and how do you create one that exposes only a subset of health indicators?
basics
~10 sA health group bundles a chosen subset of health indicators under a named sub-endpoint. You configure it with management.endpoint.health.group.<name>.include=<indicators>, then read it at /actuator/health/<name>.
What is a Spring Boot HealthIndicator and how do you implement one that reports UP or DOWN?
basics
~10 sA HealthIndicator is a bean that reports the health of one dependency. You implement the health() method to return Health.up() when things work or Health.down() when they don't, and Spring exposes it at /actuator/health.
What is the difference between the liveness and readiness probes exposed by Spring Boot Actuator, and what does Kubernetes do with each?
basics
~20 sLiveness says the app is running and healthy; if it fails, Kubernetes restarts the pod. Readiness says the app can accept traffic right now; if it fails, Kubernetes stops routing requests to it but does not restart.
In Spring Boot Actuator, what does management.endpoint.health.show-details control, and what are its three possible values?
basics
~10 sIt controls how much detail /actuator/health shows. Values: never (default, only overall status), when-authorized (details shown to logged-in/authorized users), and always (details shown to everyone).
What meters does Spring Boot auto-configure out of the box, and what is a MeterBinder?
basics
~20 sWith Actuator + Micrometer on the classpath, Boot auto-registers meters for JVM memory/GC/threads, CPU, process, HTTP requests, datasource, and logback events. A MeterBinder is a small class that binds one such set of metrics to the MeterRegistry.
What is a Micrometer Counter and when should you use one instead of a Gauge?
basics
~20 sA Counter records a value that only ever goes up (a total, like requests served). Use a Counter for cumulative counts you increment; use a Gauge for a value that can go up and down, like current queue size.
How do you expose your Spring Boot application's metrics to Prometheus, and what is the /actuator/prometheus endpoint?
basics
~10 sAdd the micrometer-registry-prometheus dependency and expose the endpoint with management.endpoints.web.exposure.include=prometheus. Spring Boot then serves metrics as plain text at /actuator/prometheus, which the Prometheus server reads (scrapes).
What is a Micrometer MeterRegistry, and what role does it play in a Spring Boot application?
basics
~10 sMeterRegistry is Micrometer's central object that creates and holds meters (counters, gauges, timers). Spring Boot auto-configures one and injects it, so your code records metrics through it without knowing which monitoring backend receives them.
What are dimensional tags on a Micrometer meter, and why do they matter?
basics
~10 sTags are key/value labels (like method=GET, status=200) attached to a meter. They let you slice one metric by dimensions and filter or group in your monitoring system instead of creating many separate metrics.
What is Micrometer Tracing, and what does a 'tracing bridge' (bridge-otel / bridge-brave) actually do?
basics
~20 sMicrometer Tracing is a vendor-neutral facade for distributed tracing. A bridge plugs a real tracer (OpenTelemetry or Brave/Zipkin) behind that facade, so your code uses one API while the bridge does the actual span work.
What does the @Observed annotation do in Spring, and what bean must you register for it to work?
basics
~20 s@Observed marks a method so Micrometer creates an Observation around each call (producing metrics and/or a trace span). For it to work you must register an ObservedAspect bean, which uses Spring AOP to wrap the annotated method.
What is Micrometer's Observation API, and how do you record a piece of work using an ObservationRegistry?
basics
~20 sThe Observation API lets you wrap a piece of code once so Spring can produce monitoring signals from it. You create an Observation on an ObservationRegistry with a name and call observe(...) around your code.
What is trace context propagation, and what does the W3C traceparent header carry across an HTTP call?
basics
~20 sContext propagation passes the current trace's IDs to the next service so their spans join one trace. With Micrometer Tracing, Spring auto-adds a W3C traceparent header carrying the trace ID, the caller's span ID, and a sampled flag.
What does the management.tracing.sampling.probability property do in Spring Boot, and what is its default value?
basics
~10 sIt sets the fraction of traces that get recorded and exported, from 0.0 (none) to 1.0 (all). The default in Spring Boot is 0.1, meaning about 10% of traces are sampled.
What is the default logging setup in a Spring Boot application, and what role does SLF4J play?
basics
~10 sSpring Boot uses Logback as the default logging backend, pulled in via spring-boot-starter-logging. Your code logs through SLF4J, a facade/API, and SLF4J routes those calls to Logback at runtime.
What are the Spring Boot log levels, how are they ordered, and how do you set the threshold for a specific logger?
basics
~10 sLevels from least to most severe: TRACE, DEBUG, INFO, WARN, ERROR. Setting a logger to a level shows that level and everything more severe. Configure with logging.level.<logger>, e.g. logging.level.org.springframework.web=DEBUG. Default root level is INFO.
How do you turn on JSON structured logging in Spring Boot 3.4, and why would you want it?
basics
~10 sSet logging.structured.format.console=ecs (or logstash/gelf) in application.properties. Boot then prints each log line as one JSON object instead of plain text, so log aggregators like Elasticsearch or Loki can parse fields automatically.
Why use logback-spring.xml instead of logback.xml, and what do <springProfile> and <springProperty> do?
basics
~10 slogback-spring.xml is loaded by Spring Boot (not raw Logback), so it supports Spring's extensions: <springProfile> includes config only for certain active profiles, and <springProperty> pulls values from Spring's Environment (application.yml) into the Logback config.
How does Spring Boot get traceId and spanId into log lines by default? Explain the pattern, MDC, and what enables it.
basics
~20 sAdd Micrometer Tracing to the classpath. When a span is active it copies traceId and spanId into SLF4J's MDC (a thread-local map). Spring Boot's default log pattern includes a correlation part that prints those MDC values as [app,traceId,spanId].