Modern applications need to be observable, monitorable, and resilient. Thatβs where Spring Boot Actuator shines β it exposes production-ready features like health checks, metrics, auditing, info endpoints, and more.
In this guide, weβll explore how to configure and use Spring Boot Actuator Health Checks, Metrics, and Monitoring endpoints in a typical application.

π¦ What is Spring Boot Actuator?
Spring Boot Actuator is a subproject that adds a set of REST endpoints to your application to help you monitor and manage it in production.
With a simple dependency, you gain access to:
/actuator/health
β check if your app is alive/actuator/metrics
β runtime metrics/actuator/env
,/actuator/info
, and more
π§° Step 1: Add Actuator to Your Project
β Maven Dependency
1 2 3 4 5 6 7 |
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> |
βοΈ Step 2: Basic Configuration
π application.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
management: endpoints: web: exposure: include: health, metrics, info, env, prometheus endpoint: health: show-details: always info: env: enabled: true |
You can choose to expose only specific endpoints or all (include: '*'
for development).
π‘οΈ Health Checks
π Endpoint: /actuator/health
The health endpoint reports whether the application is healthy. It integrates with:
- DB
- Disk space
- Redis
- RabbitMQ
- Custom checks
Example Output:
1 2 3 4 5 6 7 8 9 10 |
{ "status": "UP", "components": { "db": { "status": "UP" }, "diskSpace": { "status": "UP" } } } |
β Add DB Health Indicator
If using a datasource, Spring Boot will auto-configure a DataSourceHealthIndicator
.
You can also create your own:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
package com.kscodes.springboot.monitoring.health; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.stereotype.Component; @Component public class CustomHealthCheck implements HealthIndicator { @Override public Health health() { boolean serviceUp = checkMyService(); return serviceUp ? Health.up().withDetail("custom", "Service OK").build() : Health.down().withDetail("custom", "Service FAILED").build(); } private boolean checkMyService() { // Ping or validate logic return true; } } |
π Metrics Endpoint
π Endpoint: /actuator/metrics
Gives runtime statistics like:
- JVM memory usage
- CPU
- HTTP request counts and timing
- Garbage collection
- Thread states
To view metric names:
1 2 3 4 |
GET /actuator/metrics |
To get details of one:
1 2 3 4 |
GET /actuator/metrics/jvm.memory.used |
Sample Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{ "name": "jvm.memory.used", "measurements": [; { "statistic": "VALUE", "value": 16570000.0 } ], "availableTags": [; { "tag": "area", "values": ["heap", "nonheap"] }, { "tag": "id", "values": ["G1 Old Gen", "Code Cache"] } ] } |
π₯οΈ Info Endpoint
π§Ύ /actuator/info
Enrich this with build or environment data.
Example:
1 2 3 4 5 6 7 8 |
info: app: name: Spring Boot Monitoring App version: 1.0.1 description: App to demonstrate actuator |
1 2 3 4 5 6 7 8 |
info: app: name: Spring Boot Monitoring App version: 1.0.1 description: App to demonstrate actuator |
π¦ Step 3: Integrate with Prometheus & Grafana
Add Micrometer Prometheus:
1 2 3 4 5 6 7 |
<dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency> |
Enable /actuator/prometheus
1 2 3 4 5 6 7 8 |
management: endpoints: web: exposure: include: prometheus |
Prometheus Setup
Add this scrape config in your prometheus.yml
:
1 2 3 4 5 6 7 8 |
scrape_configs: - job_name: 'spring-boot-app' metrics_path: '/actuator/prometheus' static_configs: - targets: ['localhost:8080'] |
Now you can visualize metrics in Grafana using Prometheus as data source.
π‘οΈ Securing Actuator Endpoints
By default, most endpoints are secure. Use Spring Security to restrict access.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
@Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(auth -> auth .requestMatchers("/actuator/health").permitAll() .requestMatchers("/actuator/**").hasRole("ADMIN") .anyRequest().authenticated() ); return http.build(); } |
π§ͺ Bonus: Enable HTTP Trace
1 2 3 4 5 6 7 8 9 10 11 12 |
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator-autoconfigure</artifactId> </dependency> |
1 2 3 4 5 6 7 8 9 10 11 |
management: endpoint: httptrace: enabled: true endpoints: web: exposure: include: httptrace |
Access /actuator/httptrace
to see incoming HTTP requests for diagnostics.
β Summary
- Spring Boot Actuator Health Checks are key to reliable applications.
- Use
/actuator/health
,/actuator/metrics
,/actuator/info
, and/actuator/prometheus
for complete monitoring. - Integrate with Prometheus & Grafana for visualization.
- Use custom health indicators for app-specific checks.