Introduction

Spring Boot Actuator provides production-ready features to help you monitor and manage your application. It exposes useful HTTP endpoints such as /actuator/health, /actuator/env, /actuator/beans and many more.

During this exercise we will add the Actuator to our CarApp and explore the available endpoints.

Learning objectives

By the end of this exercise, you should be able to:
  • Add the Actuator dependency to a Spring Boot project

  • Configure which endpoints are exposed

  • Use the Actuator endpoints to inspect the state of your application

Getting started

Step 1: Add the dependency

Add the following to your pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
That is the only dependency needed. The old spring-boot-actuator-docs artifact no longer exists and is not required.

Step 2: Configure the endpoints

Add the following to your application.properties:

# Expose all actuator endpoints over HTTP (for development/training only!)
management.endpoints.web.exposure.include=*

# Show full health details (default is 'never')
management.endpoint.health.show-details=always
Exposing all endpoints with * is fine for development and training, but in production you should only expose the endpoints you actually need, e.g. management.endpoints.web.exposure.include=health,info,metrics. Sensitive endpoints like env, beans, and configprops can leak internal configuration details.
The base path for all actuator endpoints is /actuator by default. You can change this with management.endpoints.web.base-path=/manage if desired.

Step 3: Restart and explore

Restart the application and open Postman (or your browser).

Discover all available endpoints

This returns a list of all exposed endpoints with their URLs (HATEOAS style).

Useful endpoints to explore

Endpoint URL Description

health

http://localhost:8080/actuator/health

Shows application health status (UP/DOWN) and details about disk space, database, etc.

info

http://localhost:8080/actuator/info

Shows application info (if configured in application.properties)

beans

http://localhost:8080/actuator/beans

Lists all Spring beans registered in the application context

env

http://localhost:8080/actuator/env

Shows all environment properties (profiles, system properties, application.properties values)

configprops

http://localhost:8080/actuator/configprops

Shows all @ConfigurationProperties beans and their current values

metrics

http://localhost:8080/actuator/metrics

Lists all available metrics. Drill into a specific metric with /actuator/metrics/{metric.name}

mappings

http://localhost:8080/actuator/mappings

Shows all @RequestMapping paths — very useful to see all your REST endpoints at a glance

threaddump

http://localhost:8080/actuator/threaddump

Shows a thread dump of the JVM

loggers

http://localhost:8080/actuator/loggers

Shows and allows changing log levels at runtime

Exercise

Step 1: Explore the endpoints
  • Open each of the endpoints listed above in Postman or your browser

  • Look at the health endpoint — what components does it report on?

  • Look at the beans endpoint — can you find your own CarController, CarService and CarRepository?

  • Look at the mappings endpoint — can you find all your REST endpoints?

  • Look at the metrics endpoint — open /actuator/metrics/jvm.memory.used to see the current JVM memory usage

Step 2: Try the env endpoint
  • Open /actuator/env and find your database connection properties

  • Try /actuator/env/spring.datasource.url to get a single property

Step 3: Change a log level at runtime (bonus)
  • Open /actuator/loggers/com.acme.carapp to see the current log level

  • Use Postman to send a POST request to /actuator/loggers/com.acme.carapp with the following JSON body to change the log level to DEBUG:

{
    "configuredLevel": "DEBUG"
}
  • Verify by opening /actuator/loggers/com.acme.carapp again — the level should now be DEBUG

  • Make some requests to your CarController and observe the additional debug logging in the console

Takeaway

In this exercise, you learned how to add the Spring Boot Actuator to your project and explored the available endpoints for monitoring and managing your application. In a production environment, these endpoints are essential for health checking (e.g. in Kubernetes liveness/readiness probes) and observability.

Further reading