Spring Boot Tutorial
Spring Boot - Software Setup and Configuration (STS/Eclipse/IntelliJ)
Prerequisite (Spring Core Concepts)
Spring Boot Core
Spring Boot with REST API
Spring Boot with Database and Data JPA
Spring Boot with Kafka
Spring Boot with AOP
Spring Boot Actuator is a sub-project of Spring Boot, which adds production-ready features to your application without needing to write these components yourself. It's incredibly beneficial for monitoring and managing production applications, exposing various features via HTTP endpoints and JMX.
Health Checks: Shows the health of the application. It can be easily extended to check the health of data sources, caches, and other external systems.
Metrics Collection: Collects and exposes a large range of application metrics like JVM, garbage collection, web requests, and custom metrics.
Application Environment: Displays properties and configurations of the application.
Auditing: Tracks user activity and authentication events.
HTTP Traces: Keeps a log of the latest HTTP requests.
Beans Information: Displays all beans and their relationships in the application context.
Shutdown: Allows the application to be gracefully shut down (should be used carefully).
And more...
To use Spring Boot Actuator, you simply need to add the actuator starter dependency to your project.
For Maven:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
For Gradle:
implementation 'org.springframework.boot:spring-boot-starter-actuator'
Once the dependency is added, various actuator endpoints become available at the default /actuator
path. For example:
/actuator/health
/actuator
/actuator/metrics
/actuator/env
Out of the box, many sensitive actuator endpoints are secured and not exposed over HTTP. You might want to expose them depending on your needs, but you must be careful and ensure they're protected, especially in a production environment.
For example, to expose all endpoints:
management.endpoints.web.exposure.include=*
To expose specific endpoints:
management.endpoints.web.exposure.include=health,info,metrics
Actuator provides numerous properties and extension points for customization:
You can change the base path using management.endpoints.web.base-path
.
Add custom health indicators.
Extend existing or create new endpoints.
Spring Boot Actuator simplifies the process of adding production-ready features to your application. Whether you need detailed metrics, health checks, or application insights, Actuator has you covered. Just remember to always secure sensitive endpoints, especially in production environments.
Customizing Spring Boot Actuator endpoints:
Endpoint
class and customize endpoint behavior.@Endpoint(id = "custom") public class CustomEndpoint { // Custom implementation }
Configuring Spring Boot Actuator in application.properties:
application.properties
.management.endpoints.web.exposure.include=health,info
Enabling and disabling specific Actuator endpoints:
management.endpoints.web.exposure.include
and management.endpoints.web.exposure.exclude
properties.management.endpoints.web.exposure.include=health,info