Spring Boot Actuator Tutorial: Monitor and Manage Spring Boot Applications
Introduction
Building a Spring Boot application is only part of the job.
Once an application is deployed to production, developers and system administrators need to know whether it is healthy, how it is performing, and whether important components such as databases and external services are working correctly.
This is where Spring Boot Actuator becomes useful.
Spring Boot Actuator provides production-ready features for monitoring and managing applications, including health information, metrics, application information, and management endpoints.
In this tutorial, you'll learn:
- What Spring Boot Actuator is
- How to add Actuator to a Spring Boot project
- How to enable management endpoints
-
How to use the
/actuator/healthendpoint - How to expose application information
- How to view metrics
- How to configure Actuator
- How to secure Actuator endpoints
- How Actuator can be used in production
- Common Actuator mistakes and best practices
What is Spring Boot Actuator?
Spring Boot Actuator is a Spring Boot module that provides features for monitoring and managing running applications.
Instead of manually writing endpoints to check your application's condition, Actuator provides built-in management capabilities.
For example:
/actuator/health
can provide information about application health.
Other endpoints can provide information about:
- Metrics
- Loggers
- Mappings
- Application information
- Scheduled tasks
- Environment information
- Beans
- Caches
The exact endpoints available depend on the Spring Boot version and configuration.
Why Do We Need Spring Boot Actuator?
Imagine your Spring Boot application is running on a production server.
A user reports:
"The application is not working."
Without monitoring tools, you might have to inspect logs and manually investigate the server.
With Actuator, you can expose health and monitoring information that can help you determine whether the application itself and its dependencies are healthy.
A simplified architecture looks like this:
Spring Boot Application│↓Spring BootActuator│┌─────────────┼─────────────┐↓ ↓ ↓Health Metrics Info│ │ │↓ ↓ ↓/actuator/health /metrics /info
Add Spring Boot Actuator Dependency
For a Maven project, add the Actuator starter to your pom.xml.
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
Place this inside the <dependencies> section of your Maven project.
Spring Boot provides the Actuator starter specifically for adding these production-ready features.
Start the Spring Boot Application
After adding the dependency, start your application normally.
For example:
mvn spring-boot:run
If your application starts successfully, you can access the default health endpoint.
http://localhost:8080/actuator/health
A healthy application can return a response similar to:
{"status": "UP"}
Spring's own getting-started documentation demonstrates this health endpoint.
What is the Health Endpoint?
The health endpoint is one of the most useful Actuator features.
/actuator/health
It tells you about the application's health status.
For example:
{"status": "UP"}
Possible high-level statuses can include:
UPDOWNUNKNOWNOUT_OF_SERVICE
The health system can also incorporate information from configured application components and dependencies.
Why is Health Monitoring Important?
Health checks are particularly useful when your application runs in:
- Docker
- Kubernetes
- Cloud environments
- Microservices architectures
- Load-balanced environments
- Production servers
For example:
Load Balancer↓Spring Boot Application↓/actuator/health↓Healthy?↙ ↘YES NO↓ ↓Traffic RemoveContinues Instance
This allows infrastructure systems to determine whether an application instance is available.
Actuator Endpoints
Spring Boot Actuator provides several endpoints.
Some commonly used endpoints include:
| Endpoint | Purpose |
|---|---|
/actuator/health | Application health |
/actuator/info | Application information |
/actuator/metrics | Application metrics |
/actuator/loggers | Logger information |
/actuator/mappings | Request mappings |
/actuator/beans | Spring beans |
/actuator/env | Environment information |
/actuator/scheduledtasks | Scheduled tasks |
Spring Boot documents these as built-in Actuator endpoints, with exposure and availability controlled through configuration.
Are All Actuator Endpoints Public by Default?
No.
This is extremely important.
Spring Boot does not expose every management endpoint over HTTP by default.
The current Spring Boot documentation states that only the health endpoint is exposed over HTTP by default, and endpoints can be explicitly included or excluded.
This is important because some endpoints can expose sensitive application information.
Expose Additional Endpoints
You can configure endpoint exposure in:
src/main/resources/application.properties
For example:
management.endpoints.web.exposure.include=health,info,metrics
Now these endpoints can be exposed:
/actuator/health/actuator/info/actuator/metrics
Expose All Endpoints
You may see tutorials recommending:
management.endpoints.web.exposure.include=*
This exposes all available web endpoints.
Do not blindly use this configuration on a public production application.
Actuator endpoints can contain sensitive information, and Spring's documentation specifically recommends carefully considering which endpoints are exposed and securing them when appropriate.
For learning purposes, however, exposing additional endpoints locally can help you understand how Actuator works.
Configure Application Information
You can provide application information through:
management.info.env.enabled=true
For example:
info.app.name=Java Web Actioninfo.app.description=Java and Spring Boot tutorialsinfo.app.version=1.0.0
Then access:
/actuator/info
Depending on your Spring Boot version and configuration, this can return application information.
Understanding Metrics
The metrics endpoint provides access to application metrics.
/actuator/metrics
Spring Boot's Actuator documentation describes the endpoint as providing access to metrics recorded by the application.
For example:
http://localhost:8080/actuator/metrics
The response can contain available metric names.
A metric might represent information related to:
- JVM memory
- CPU-related measurements
- HTTP requests
- Database activity
- Application performance
The exact metrics available depend on your application and configuration.
Viewing a Specific Metric
Once you have a metric name, you can request it.
For example:
/actuator/metrics/jvm.memory.used
This allows you to inspect a specific metric rather than retrieving the entire metric list.
Actuator and JVM Monitoring
One major advantage of Actuator is that it can expose useful JVM-related metrics.
For example:
JVM MemoryJVM ThreadsGarbage CollectionCPU-related Metrics
This can help developers investigate application performance problems.
Change the Actuator Base Path
By default, Actuator endpoints use:
/actuator
For example:
/actuator/health
You can customize the base path.
management.endpoints.web.base-path=/manage
The health endpoint would then become:
/manage/health
Spring Boot's Actuator documentation confirms that the web base path can be customized.
Put Actuator on a Separate Port
For some production architectures, you may want management endpoints on a different port.
Example:
management.server.port=8081
Your application might continue running on:
8080
while management endpoints use:
8081
Spring Boot supports configuring a separate management server port.
This can be useful when management traffic needs to be isolated from normal application traffic.
Secure Actuator Endpoints
Security should be one of your highest priorities when deploying Actuator.
For example, don't expose sensitive endpoints publicly without understanding exactly what information they provide.
A safer approach is to expose only the endpoints you actually need.
For example:
management.endpoints.web.exposure.include=health,info
Then use Spring Security or your infrastructure's access controls to protect management endpoints where appropriate.
Actuator with Spring Security
If your project already uses Spring Security, you can apply authorization rules to Actuator endpoints.
For example, conceptually:
Public Users│↓Application APIsAdministrators│↓Actuator Endpoints
This is particularly important for endpoints that can reveal configuration, environment details, beans, mappings, or other internal information.
Actuator in Microservices
Actuator becomes particularly useful in microservice architectures.
Imagine:
API Gateway│┌──────────────┼──────────────┐↓ ↓ ↓User Service Order Service Payment Service│ │ │↓ ↓ ↓Health Health Health
Each service can provide health information.
A monitoring system can then determine which services are operational.
Actuator with Docker and Kubernetes
Containerized applications benefit from health endpoints because orchestration systems need ways to determine whether an application is ready and healthy.
For example:
Kubernetes│├── Application Pod 1│ └── /actuator/health│├── Application Pod 2│ └── /actuator/health│└── Application Pod 3└── /actuator/health
Spring Boot also provides dedicated health groups and Kubernetes-related health probe support.
Actuator and Prometheus
Actuator can also expose metrics in a format suitable for Prometheus when the appropriate Prometheus registry dependency is included.
The Actuator documentation lists the prometheus endpoint and notes that it requires micrometer-registry-prometheus.
A common monitoring architecture looks like:
Spring Boot│↓Spring Boot Actuator│↓Micrometer│↓Prometheus│↓Grafana
This is a common direction for production observability.
Actuator vs Application REST APIs
It's important to understand that Actuator endpoints are not the same thing as your application's REST endpoints.
Your application might have:
/api/employees/api/products/api/orders
Actuator provides management endpoints such as:
/actuator/health/actuator/info/actuator/metrics
The first group is your application's business functionality.
The second group is primarily for monitoring and management.
Common Actuator Mistakes
Mistake 1: Exposing Everything
Avoid:
management.endpoints.web.exposure.include=*
on a publicly accessible application unless you fully understand and secure the resulting exposure.
Mistake 2: Ignoring Security
Management endpoints should be treated as potentially sensitive.
Mistake 3: Using Actuator Only in Production
It's useful during development too.
You can use health and metrics information while diagnosing application behavior locally.
Mistake 4: Assuming Health Means Everything Is Perfect
A health response is only one part of monitoring.
A production monitoring strategy should also consider:
- Logs
- Metrics
- Traces
- Alerts
- Infrastructure
- Database health
- External dependencies
Spring Boot Actuator Best Practices
Expose Only What You Need
Don't expose every management endpoint unnecessarily.
Protect Sensitive Endpoints
Use authentication, authorization, network controls, or a combination of these.
Monitor Health
Use health information to determine whether services are operational.
Monitor Metrics
Metrics can help identify performance problems before users report them.
Use Centralized Monitoring
For larger applications, integrate Actuator metrics with your monitoring stack.
Don't Treat Actuator as a Complete Monitoring Platform
Actuator provides the application-side instrumentation and management endpoints. Your overall monitoring architecture may also require systems such as Prometheus, Grafana, centralized logging, and alerting.
Spring Boot Actuator Architecture
Spring Boot Application│┌────────┴────────┐│ │Business APIs Actuator│ ││ ┌─────────┼─────────┐│ ↓ ↓ ↓│ Health Info Metrics│ │ │ │└───────┴─────────┴─────────┘│↓Monitoring│┌────────────┼────────────┐↓ ↓ ↓Prometheus Grafana Alerts
Frequently Asked Questions
What is Spring Boot Actuator?
Spring Boot Actuator provides production-ready monitoring and management features for Spring Boot applications.
What is the default Actuator health URL?
The default web endpoint is:
/actuator/health
Does Spring Boot expose all Actuator endpoints?
No. Only the health endpoint is exposed over HTTP by default in the current documentation; additional endpoints must be configured for exposure.
Can I change /actuator to another path?
Yes.
For example:
management.endpoints.web.base-path=/manage
Can Actuator monitor application metrics?
Yes. The metrics endpoint provides access to application metrics.
Is Spring Boot Actuator useful for microservices?
Yes. Health and metrics endpoints are especially useful when multiple Spring Boot services need to be monitored.
Conclusion
Spring Boot Actuator is an important tool for developers building production-ready Spring Boot applications.
It provides convenient endpoints for health information, metrics, application information, and other management functions.
The most important lesson is that monitoring is part of application development, not something to think about only after deployment.
For a small application, /actuator/health may be enough to get started. As your application grows, you can integrate Actuator with metrics, dashboards, alerting, and centralized monitoring systems.
