Spring Boot Actuator provides production-ready features to monitor and manage your applications. This guide explores Actuator's capabilities, how to enable it, and secure its endpoints.
Written by
Şuayb Şimşek
Backend-focused fullstack developer sharing practical notes on Spring Boot, security, microservices, and cloud-native architecture.
By default, Actuator exposes several endpoints to provide application insights. You can enable these endpoints in your application.properties or application.yml file.
Configuration Example:
Use this configuration as a baseline and adjust values for your local or production environment.
You can access these endpoints via a browser or API tools like cURL.
Example:
BASH
curl -X GET http://localhost:8080/actuator/health
🛠️ Step 4: Customize Actuator Endpoints
You can customize Actuator endpoints to suit your needs. For example, you can define additional metadata in the application.properties file for the /actuator/info endpoint:
PROPERTIESconfig.properties
info.app.name=My Application
info.app.version=1.0.0
info.app.description=Spring Boot Actuator Example
🛠️ Step 5: Secure Actuator Endpoints
For production environments, it's essential to secure Actuator endpoints. Use Spring Security to restrict access.
▶️ Running the Application
Run the application using the following command:
BASH
./mvnw spring-boot:run
Access the Actuator endpoints at:
FILENAME
http://localhost:8080/actuator/health
🧪 Test the API
You can test the Actuator endpoints using cURL or browser:
Health Endpoint:
BASH
curl -X GET http://localhost:8080/actuator/health
Info Endpoint:
BASH
curl -X GET http://localhost:8080/actuator/info
🏁 Conclusion
You now have a practical Spring Boot Actuator implementation with a clear, production-friendly Spring Boot structure. As a next step, adapt configuration and tests to your own domain, then validate behavior under realistic traffic and failure scenarios.
Example Security Configuration
JAVASecurityConfig.java
package com.example.demo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SecurityConfig {
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests()
.requestMatchers("/actuator/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.httpBasic();
return http.build();
}
}