Spring Boot starter that provides comprehensive production-ready monitoring and management capabilities for applications
npx @tessl/cli install tessl/maven-org-springframework-boot--spring-boot-starter-actuator@3.5.0Spring Boot Starter Actuator provides comprehensive production-ready monitoring and management capabilities for Spring Boot applications. It automatically configures actuator endpoints that expose operational information through HTTP endpoints or JMX beans, enabling health checks, metrics collection, application information, and other management features without requiring manual configuration.
pom.xml or build.gradleMaven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Gradle:
implementation 'org.springframework.boot:spring-boot-starter-actuator'// Basic Spring Boot application with actuator
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}Configuration in application.properties:
# Expose all actuator endpoints over HTTP
management.endpoints.web.exposure.include=*
# Change actuator base path (default: /actuator)
management.endpoints.web.base-path=/actuator
# Show health details to everyone
management.endpoint.health.show-details=alwaysAfter starting the application, actuator endpoints are available at:
http://localhost:8080/actuator/healthhttp://localhost:8080/actuator/infohttp://localhost:8080/actuator/metricsSpring Boot Starter Actuator is built around several key components:
Core system for creating custom actuator endpoints using annotations and interfaces.
// Create custom endpoints
@Endpoint(id = "custom")
public class CustomEndpoint {
@ReadOperation
public Map<String, Object> customInfo() {
return Map.of("status", "operational");
}
}
// Core endpoint annotations
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Endpoint {
String id();
Access defaultAccess() default Access.RESTRICTED;
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReadOperation {
String[] produces() default {};
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface WriteOperation {
String[] produces() default {};
}Comprehensive health monitoring with built-in indicators and support for custom health checks.
// Create custom health indicators
@Component
public class CustomHealthIndicator implements HealthIndicator {
@Override
public Health health() {
// Check health of external service
if (isServiceHealthy()) {
return Health.up()
.withDetail("service", "operational")
.build();
}
return Health.down()
.withDetail("service", "unavailable")
.build();
}
}
// Core health interfaces
public interface HealthIndicator {
Health health();
default Health getHealth(boolean includeDetails) {
return health();
}
}
public final class Health {
public static Builder up() { /* ... */ }
public static Builder down() { /* ... */ }
public static Builder outOfService() { /* ... */ }
}Production-ready endpoints for monitoring, management, and diagnostics.
// Key built-in endpoints
@Endpoint(id = "health")
public class HealthEndpoint {
@ReadOperation
public HealthComponent health() { /* ... */ }
@ReadOperation
public HealthComponent healthForPath(@Selector String... path) { /* ... */ }
}
@Endpoint(id = "info")
public class InfoEndpoint {
@ReadOperation
public Map<String, Object> info() { /* ... */ }
}
@Endpoint(id = "metrics")
public class MetricsEndpoint {
@ReadOperation
public ListNamesResponse listNames() { /* ... */ }
@ReadOperation
public MetricResponse metric(@Selector String requiredMetricName,
@Nullable List<String> tag) { /* ... */ }
}Integration with Micrometer for comprehensive metrics collection and export.
// Metrics endpoint for accessing collected metrics
@Endpoint(id = "metrics")
public class MetricsEndpoint {
@ReadOperation
public ListNamesResponse listNames() { /* ... */ }
@ReadOperation
public MetricResponse metric(@Selector String requiredMetricName,
@Nullable List<String> tag) { /* ... */ }
}
// Configure automatic timing
public class AutoTimer {
public static final AutoTimer ENABLED = new AutoTimer(true);
public static final AutoTimer DISABLED = new AutoTimer(false);
}
// Prometheus integration
@Endpoint(id = "prometheus", enableByDefault = false)
public class PrometheusScrapeEndpoint {
@ReadOperation(produces = "text/plain;version=0.0.4;charset=utf-8")
public String scrape() { /* ... */ }
}Comprehensive configuration options for customizing actuator behavior.
// Web endpoint configuration
@ConfigurationProperties("management.endpoints.web")
public class WebEndpointProperties {
private String basePath = "/actuator";
private PathMappingCache pathMapping = new PathMappingCache();
private Exposure exposure = new Exposure();
// ... getters and setters
}
// Health endpoint configuration
@ConfigurationProperties("management.endpoint.health")
public class HealthEndpointProperties {
private Show showDetails = Show.NEVER;
private Show showComponents = Show.ALWAYS;
private Map<String, GroupProperties> group = new LinkedHashMap<>();
// ... getters and setters
}Spring Boot Actuator provides several extension points for customization:
@Endpoint annotationHealthIndicator interfaceInfoContributor interfaceMeterRegistry integration@EndpointWebExtension for web-specific functionalityActuator endpoints can expose sensitive information. Key security features:
RESTRICTED, UNRESTRICTED)management.endpoints.web.exposure.include/env, /configprops) can expose sensitive configuration# Expose specific endpoints
management.endpoints.web.exposure.include=health,info,metrics
# Change management port
management.server.port=8081
# Show health details only when authorized
management.endpoint.health.show-details=when-authorized
# Configure health groups
management.endpoint.health.group.custom.include=db,redis
management.endpoint.health.group.custom.show-details=always