Back to Master Spring Boot
    Topic 4

    Using Actuator

    Monitor and manage your application in production with Spring Boot Actuator - health checks, metrics, and custom endpoints

    Managing and Monitoring Applications with Spring Boot Actuator

    The Spring Boot Actuator provides production-ready functionality for your application. This tool allows you to easily monitor your application, collect metrics, and understand its status or database activity. Professional-grade tools are available without having to build from scratch.

    The Actuator exposes important operational data about the running application, such as health, metrics, and information. The Actuator uses HTTP endpoints or Java Management Extensions (JMX), making it easy to interact with.

    Health Monitoring

    Application status checks

    Metrics Collection

    Performance data gathering

    System Information

    Environment & config details

    Once integrated, the Actuator provides multiple default endpoints and, like other Spring modules, is easy to configure and extend.

    Configure the Spring Boot Actuator

    Add Actuator Dependency

    To add the Actuator to a Maven-based project, add the following dependency:

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

    This configuration applies to all Spring Boot versions because the version is covered in the Spring Boot Bill of Materials (BOM).

    Configure Actuator Endpoints

    By default, Spring Boot applications only expose the health endpoint. To observe the configuration and the configurable environment, you can enable additional endpoints.

    Step 1: Add Environment Variables

    Go to the application's "Overview" pane, select "Configuration" from the "Settings" menu, and then go to the "Environment Variables" configuration page.

    Step 2: Configure Endpoints

    Add the following property to enable health, env, and configprops endpoints:

    application.properties
    management.endpoints.web.exposure.include:health,env,configprops

    Step 3: Save and Restart

    Select "Save". The application will automatically restart and load the new environment variables. Wait for "Provisioning Status" to change to "Success".

    To view the built-in and related configurations of all endpoints, see the Public Endpoints section of Spring Boot Production Ready Features documentation.

    Common Actuator Endpoints

    /actuator/health

    Shows application health information

    /actuator/env

    Displays environment properties

    /actuator/info

    Shows arbitrary application info

    /actuator/metrics

    Shows metrics information

    /actuator/configprops

    Shows @ConfigurationProperties

    /actuator/beans

    Displays all Spring beans

    Protect Actuator Endpoints

    Security Warning

    Once the application is exposed, these actuator endpoints will also be exposed. It is recommended to hide all endpoints in production environments.

    To hide all endpoints by default, set the following property. The exclude property takes precedence over the include property:

    application.properties
    management.endpoints.web.exposure.exclude=*

    This will prevent application live views and other applications or tools that rely on actuator HTTP endpoints from being displayed in enterprise applications. Configure selectively based on your security requirements.

    Summary

    Spring Boot Actuator provides production-ready features for monitoring and managing applications.

    Use HTTP endpoints or JMX to interact with the Actuator.

    Configure which endpoints are exposed using management.endpoints.web.exposure properties.

    Always secure actuator endpoints in production environments.

    💬 Comments & Discussion