Monitoring with Actuator
Spring Boot Actuator bolts production-ready endpoints onto your app — /actuator/health , /actuator/metrics , /actuator/info — with Micrometer collecting metrics you can export anywhere.
Learn Monitoring with Actuator in our free Java course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick reference.
Part of the free Java course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Before You Start
You should be comfortable building a Spring Boot app and tweaking its configuration and profiles . Knowing a little about HTTP endpoints and JSON helps when reading the responses.
What You'll Learn
The Big Idea — The Dashboard of Your Application
💡 Analogy: Actuator is the dashboard and warning lights of your application, like a car's instrument cluster. /actuator/health is the big green "all systems go" light — and if the oil, brakes, or engine (any component) fails, it flips to red. /actuator/metrics is the set of gauges: speed, RPM, fuel — live numbers about how hard the engine is working. /actuator/info is the little plate showing the model and build. And just as you don't let strangers pop the hood and read the diagnostics port, you lock down the sensitive endpoints in production.
You don't build the dashboard yourself — Actuator wires it in; you just choose which gauges to show and to whom.
1️⃣ /health — Aggregated Status
The health endpoint combines many component checks into one status: if any indicator is DOWN, the whole app reports DOWN. The plain-Java model below shows that aggregation rule.
2️⃣ /metrics — Counters and Gauges
Metrics are collected by Micrometer . The core meter types are counters (ever-increasing totals, like request counts) and gauges (live values, like active sessions). The demo builds tiny versions to show what a registry holds.
3️⃣ Exposing Endpoints
By default only health (and info ) are exposed over HTTP. You opt into more with management.endpoints.web.exposure.include and can enrich /info with build metadata.
4️⃣ Adding a Custom HealthIndicator
Implement HealthIndicator to fold your own check (a downstream service, a queue, a license) into /actuator/health — the same aggregation you saw in section 1.
🧠 Quick Recall
Answer: DOWN — the overall status aggregates components and fails if any one fails.
Answer: Micrometer — a vendor-neutral facade that exports to many monitoring backends.
Answer: add it to management.endpoints.web.exposure.include (it isn't exposed by default).
🎯 YOUR TURN — Health Aggregation
Write overall(components) returning "UP" only when every component is up.
🧩 MINI-CHALLENGE — A Tiny Metrics Registry
Build a named-counter registry like Micrometer: increment by name, then print all metrics sorted.
Common Errors
- ❌ Expecting all endpoints by default. Only health/info are exposed over HTTP. Fix: add others to exposure.include .
- ❌ Exposing everything with * in production. Leaks sensitive data. Fix: expose only what you need and secure it.
- ❌ Showing full health details publicly. Reveals internals. Fix: show-details=when-authorized .
- ❌ Forgetting the starter dependency. No endpoints appear. Fix: add spring-boot-starter-actuator .
- ❌ Confusing counters and gauges. Counters only increase. Fix: use a gauge for values that go up and down.
- ❌ Leaving heapdump/threaddump open. DoS and disclosure risk. Fix: restrict to an internal management port.
Pro Tips
- 💡 Use /actuator/health for liveness/readiness probes in Kubernetes and load balancers.
- 💡 Export metrics to Prometheus by adding the Micrometer Prometheus registry — no code changes needed.
- 💡 Run Actuator on a separate management port ( management.server.port ) to isolate it from public traffic.
- 💡 Add custom HealthIndicator s for critical downstreams so a failure surfaces immediately.
📋 Quick Reference
Concept
Syntax / idea
Note
starter
spring-boot-starter-actuator
Adds endpoints
health
/actuator/health
UP/DOWN aggregate
metrics
/actuator/metrics
Browse meters
info
/actuator/info
App/build details
metrics lib
Micrometer
Facade to backends
counter
monotonic total
Only increases
gauge
current value
Up and down
expose
exposure.include=health,info,metrics
Opt in
custom check
implements HealthIndicator
Adds a component
secure
limit + protect endpoints
Production safety
📚 Resources / Keep Learning
- 📘 Actuator — Spring Boot reference
- 📗 Micrometer documentation
- 📗 Building a RESTful Web Service with Actuator — Spring guide
❓ Frequently Asked Questions
🎉 Lesson Complete!
You now know what Actuator adds, how /health aggregates component checks, how Micrometer collects counters and gauges behind /metrics , how to expose endpoints with exposure.include , and why sensitive endpoints must be secured in production.
Next up: Caching with @Cacheable — speeding up your app by remembering expensive results.
Practice quiz
What does Spring Boot Actuator provide?
- Production-ready endpoints for monitoring and managing your app
- A UI framework
- A build tool
- A database driver
Answer: Production-ready endpoints for monitoring and managing your app. Actuator exposes ready-made endpoints (health, metrics, info, and more) so you can monitor and manage a running application.
Which Actuator endpoint reports whether the app is up?
- /actuator/shutdown
- /actuator/health
- /actuator/beans
- /actuator/env
Answer: /actuator/health. The /actuator/health endpoint reports overall health (UP/DOWN) and aggregates component health indicators.
Which endpoint exposes application metrics?
- /actuator/info
- /actuator/threaddump
- /actuator/metrics
- /actuator/loggers
Answer: /actuator/metrics. /actuator/metrics lists metric names; /actuator/metrics/{name} shows a specific metric's measurements.
What is the /actuator/info endpoint for?
- Listing all beans
- Shutting down the app
- Streaming logs
- Showing arbitrary application info (build, git, custom details)
Answer: Showing arbitrary application info (build, git, custom details). /actuator/info surfaces general, customizable application information such as build and git details.
Which library backs Actuator's metrics collection?
- Log4j
- Micrometer
- Jackson
- Hibernate
Answer: Micrometer. Micrometer is the metrics facade Actuator uses; it can export to Prometheus, Datadog, and other monitoring systems.
By default in recent Spring Boot, which endpoint is exposed over HTTP?
- All endpoints
- None
- Only health (and info)
- Only shutdown
Answer: Only health (and info). For safety, only a minimal set (health, and info) is exposed over HTTP by default; others must be opted in.
How do you expose more endpoints over HTTP?
- management.endpoints.web.exposure.include
- server.expose=all
- spring.actuator.on=true
- endpoints.show()
Answer: management.endpoints.web.exposure.include. Set management.endpoints.web.exposure.include (e.g. health,info,metrics or *) in your configuration.
Why should you secure or limit Actuator endpoints in production?
- They are slow
- Some reveal sensitive internals (env, configprops, heapdump)
- They use too much memory always
- They break JSON
Answer: Some reveal sensitive internals (env, configprops, heapdump). Endpoints like env, configprops, and heapdump can leak sensitive data, so restrict exposure and protect them.
Micrometer acts as...
- a database
- a web server
- a vendor-neutral facade so the same metrics export to many backends
- a serializer
Answer: a vendor-neutral facade so the same metrics export to many backends. Like SLF4J for logging, Micrometer is a facade letting you instrument once and export to Prometheus, Datadog, etc.
A custom HealthIndicator lets you...
- change the server port
- rename endpoints
- disable metrics
- contribute a component's health (e.g. a downstream service) to /actuator/health
Answer: contribute a component's health (e.g. a downstream service) to /actuator/health. Implementing HealthIndicator adds your own UP/DOWN check that is aggregated into the overall health response.
Continue this course
- Previous: Testing the Data Layer
- Next: Caching with @Cacheable