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
org.springframework.boot
spring-boot-starter-actuator
βοΈ Step 2: Basic Configuration
π application.yml
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:
{
"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:
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:
GET /actuator/metrics
To get details of one:
GET /actuator/metrics/jvm.memory.used
Sample Output:
{
"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:
info:
app:
name: Spring Boot Monitoring App
version: 1.0.1
description: App to demonstrate actuator
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:
io.micrometer
micrometer-registry-prometheus
Enable /actuator/prometheus
management:
endpoints:
web:
exposure:
include: prometheus
Prometheus Setup
Add this scrape config in your prometheus.yml:
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.
@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
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-actuator-autoconfigure
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/prometheusfor complete monitoring. - Integrate with Prometheus & Grafana for visualization.
- Use custom health indicators for app-specific checks.