Spring Boot Components Hub

← Back to Home

Spring Boot Actuator

Spring Boot Actuator provides production-ready features to help you monitor and manage your application. It exposes operational information about the running application through HTTP endpoints or JMX, including health checks, metrics, and application information.

Key Features

Health Checks

Built-in health indicators for databases, disks, and custom components with detailed status information.

Metrics

Comprehensive metrics collection including JVM metrics, HTTP metrics, and custom business metrics.

Application Info

Expose application information, environment properties, and configuration details.

Management Endpoints

RESTful endpoints for monitoring, logging, and managing application lifecycle.

Use Cases

  • Health Monitoring: Checking application health for load balancers and orchestration platforms
  • Performance Metrics: Monitoring application performance and resource usage
  • Production Monitoring: Integrating with monitoring tools like Prometheus, Grafana, or Datadog
  • Debugging: Accessing runtime information for troubleshooting production issues
  • DevOps: Supporting CI/CD pipelines with health check endpoints

Example Usage

Access actuator endpoints:

GET /actuator/health          # Application health status
GET /actuator/metrics         # List all available metrics
GET /actuator/info            # Application information
GET /actuator/env             # Environment properties
GET /actuator/loggers         # View and configure loggers

Dependencies

Add the following dependency:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Configuration

Configure actuator endpoints in application.properties:

management.endpoints.web.exposure.include=health,info,metrics
management.endpoint.health.show-details=always
management.metrics.export.prometheus.enabled=true

Custom Health Indicator

Create custom health checks:

@Component
public class CustomHealthIndicator implements HealthIndicator {
    
    @Override
    public Health health() {
        // Check your custom component
        if (isHealthy()) {
            return Health.up().build();
        }
        return Health.down().withDetail("Error", "Component unavailable").build();
    }
}