Monitoring with Spring Boot Actuator
Utilize Spring Boot Actuator endpoints to monitor, manage, and inspect your application in production.
Monitoring with Spring Boot Actuator is a free Spring Boot 4 Complete Guide lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Spring Boot 4 Complete Guide learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Meet Spring Boot Actuator
Spring Boot Actuator is a powerful tool that helps you monitor and manage your application when it's running in production. Think of it as your app's built-in dashboard!
It provides production-ready features without requiring you to write much code.
- Monitoring: Check health, metrics, and environment details.
- Management: Log levels, shutdown, refresh context.
- Insight: Understand your app's internal workings.
Include Actuator in Your Project
To use Actuator, you just need to add its starter dependency to your project. This brings in all the necessary libraries.
For Maven, add this to your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Discover Actuator's Endpoints
Once Actuator is added, your application automatically exposes several "endpoints". These are HTTP URLs that provide specific information about your running app.
Some default endpoints include:
/actuator/health: Shows application health status./actuator/info: Displays general application information./actuator/metrics: Provides detailed metrics (CPU, memory, etc.).
By default, only /health and /info are exposed via web.
Run & Access Actuator
Let's create a simple Spring Boot app with Actuator. After running it, you can access the default endpoints in your browser or with a tool like curl.
Try running this and then navigate to http://localhost:8080/actuator/health.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ActuatorDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ActuatorDemoApplication.class, args);
}
}Deep Dive: The /health Endpoint
The /actuator/health endpoint is crucial for understanding your application's operational status. It aggregates information from various "health indicators".
- DiskSpace: Checks available disk space.
- DataSource: Verifies database connectivity (if configured).
- Liveness/Readiness: For Kubernetes deployments (newer versions).
It typically returns {"status": "UP"} if everything is fine, or details if something is down.
Custom Info with /info
The /actuator/info endpoint provides general information about your application. By default, it's empty, but you can easily populate it with useful details.
Add custom properties to your application.properties or application.yml:
info.app.name=MyActuatorApp
info.app.version=1.0.0
info.app.description=A demo for CoddyKitConfigure & Expose More Endpoints
By default, only /health and /info are exposed over the web. You can expose more endpoints like /beans (list all Spring beans) or /env (environment properties).
To expose all endpoints, add this to application.properties:
management.endpoints.web.exposure.include=*Monitor Performance with /metrics
The /actuator/metrics endpoint is invaluable for performance monitoring. It exposes various metrics about your application, JVM, and system.
Examples of metrics:
jvm.memory.used: Current JVM memory usage.system.cpu.usage: System CPU load.http.server.requests: Details about incoming HTTP requests.
You can query specific metrics like /actuator/metrics/jvm.memory.used for detailed data.
Build Your Own Health Checks
You can create custom health indicators to check the status of specific parts of your application, like an external service dependency or a custom cache.
Implement the HealthIndicator interface:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;
@SpringBootApplication
public class CustomHealthApp {
public static void main(String[] args) {
SpringApplication.run(CustomHealthApp.class, args);
}
}
@Component
class MyCustomHealthIndicator implements HealthIndicator {
@Override
public Health health() {
// Simulate checking an external service
boolean serviceIsUp = Math.random() > 0.5; // Randomly up or down
if (serviceIsUp) {
return Health.up().withDetail("myServiceStatus", "OK").build();
} else {
return Health.down().withDetail("myServiceStatus", "Failed").build();
}
}
}Quick Check: Actuator Endpoints
Which of the following Actuator endpoints are exposed by default over the web in a basic Spring Boot application with the Actuator dependency?
Actuator: Your App's Best Friend
Congratulations! You've learned how Spring Boot Actuator transforms your application into a production-ready, observable service.
- It provides crucial insights into your app's health and performance.
- You can easily add it with a single dependency.
- Default endpoints like
/healthand/infoare automatically available. - You can expose more endpoints and even create custom health checks.
Actuator is a must-have for any serious Spring Boot application!
Frequently asked questions
Is the “Monitoring with Spring Boot Actuator” lesson free?
Yes — the full text of “Monitoring with Spring Boot Actuator” is free to read here on the web, and the Spring Boot 4 Complete Guide course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Spring Boot 4 Complete Guide course, upgrade to CoddyKit PRO.
What will I learn in “Monitoring with Spring Boot Actuator”?
Utilize Spring Boot Actuator endpoints to monitor, manage, and inspect your application in production. You practise Spring Boot 4 Complete Guide with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Spring Boot 4 Complete Guide?
No prior experience is required. Spring Boot 4 Complete Guide on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Monitoring with Spring Boot Actuator” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Spring Boot 4 Complete Guide lesson?
Yes. Every Spring Boot 4 Complete Guide lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Dockerizing Spring Boot Applications
- Monitoring with Spring Boot Actuator
- Cloud Deployment Strategies
- Building CI/CD Pipelines for Spring Boot