skip to content

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 pageshow

explore

questions

148 · 5 sections

What is the Actuator discovery index at /actuator, and how do you find out which endpoints your running app actually exposes?

level: juniorimportance: must knowfreq 45%
basics
~10 s

GET /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.

open as a page

What do /actuator/health and /actuator/info return, and where does their content come from?

level: juniorimportance: must knowfreq 60%
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.

open as a page

How do you create a basic custom Actuator endpoint in Spring Boot, and what must you do before it becomes reachable over HTTP?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Make 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>.

open as a page

Which Actuator endpoints are reachable over HTTP by default in a Spring Boot app, and how do you expose additional ones?

level: juniorimportance: must knowfreq 78%
basics
~10 s

By 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.

open as a page

What is the Actuator /actuator/info endpoint and where does its content come from?

level: juniorimportance: must knowfreq 60%
basics
~10 s

GET /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.

open as a page

What are Spring Boot's built-in health indicators, and which ones does Actuator auto-register out of the box?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Built-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.

open as a page

What is an Actuator health group in Spring Boot, and how do you create one that exposes only a subset of health indicators?

level: juniorimportance: must knowfreq 35%
basics
~10 s

A 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>.

open as a page

What is a Spring Boot HealthIndicator and how do you implement one that reports UP or DOWN?

level: juniorimportance: must knowfreq 70%
basics
~10 s

A 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.

open as a page

What is the difference between the liveness and readiness probes exposed by Spring Boot Actuator, and what does Kubernetes do with each?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Liveness 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.

open as a page

In Spring Boot Actuator, what does management.endpoint.health.show-details control, and what are its three possible values?

level: juniorimportance: must knowfreq 70%
basics
~10 s

It 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).

open as a page

What meters does Spring Boot auto-configure out of the box, and what is a MeterBinder?

level: juniorimportance: must knowfreq 62%
basics
~20 s

With 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.

open as a page

What is a Micrometer Counter and when should you use one instead of a Gauge?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A 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.

open as a page

How do you expose your Spring Boot application's metrics to Prometheus, and what is the /actuator/prometheus endpoint?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Add 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).

open as a page

What is a Micrometer MeterRegistry, and what role does it play in a Spring Boot application?

level: juniorimportance: must knowfreq 70%
basics
~10 s

MeterRegistry 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.

open as a page

What are dimensional tags on a Micrometer meter, and why do they matter?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Tags 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.

open as a page

What is Micrometer Tracing, and what does a 'tracing bridge' (bridge-otel / bridge-brave) actually do?

level: juniorimportance: must knowfreq 62%
basics
~20 s

Micrometer 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.

open as a page

What does the @Observed annotation do in Spring, and what bean must you register for it to work?

level: juniorimportance: must knowfreq 45%
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.

open as a page

What is Micrometer's Observation API, and how do you record a piece of work using an ObservationRegistry?

level: juniorimportance: must knowfreq 55%
basics
~20 s

The 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.

open as a page

What is trace context propagation, and what does the W3C traceparent header carry across an HTTP call?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Context 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.

open as a page

What does the management.tracing.sampling.probability property do in Spring Boot, and what is its default value?

level: juniorimportance: must knowfreq 70%
basics
~10 s

It 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.

open as a page

What is the default logging setup in a Spring Boot application, and what role does SLF4J play?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Spring 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.

open as a page

What are the Spring Boot log levels, how are they ordered, and how do you set the threshold for a specific logger?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Levels 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.

open as a page

How do you turn on JSON structured logging in Spring Boot 3.4, and why would you want it?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Set 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.

open as a page

Why use logback-spring.xml instead of logback.xml, and what do <springProfile> and <springProperty> do?

level: middleimportance: must knowfreq 65%
basics
~10 s

logback-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.

open as a page

How does Spring Boot get traceId and spanId into log lines by default? Explain the pattern, MDC, and what enables it.

level: middleimportance: must knowfreq 65%
basics
~20 s

Add 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].

open as a page