In this Spring boot actuator tutorial, learn about in-built HTTP endpoints available for any boot application for different monitoring and management purposes. Before the spring framework, if we had to introduce this type of monitoring functionality in our applications then we had to manually develop all those components and that too was very specific to our need. But with spring boot we have
Actuator module which makes it very easy.
We just need to configure a few things and we are done – all the management and monitoring related information is easily available. Let’s learn to configure Spring boot 2 actuator endpoints.
1. Spring Boot Actuator Module
Spring boot’s module
Actuator allows you to monitor and manage application usages in production environment, without coding and configuration for any of them. These monitoring and management information is exposed via REST like endpoint URLs.
1.1. Actuator Maven Dependency
1.2. Important Actuator Endpoints
Most applications exposes endpoints via HTTP, where the ID of the endpoint along with a prefix of
/actuator is mapped to a URL. For example, by default, the
health endpoint is mapped to
By default, only
/info are exposed via Web APIs. Rest are exposed via JMX. Use
management.endpoints.web.exposure.include=* to expose all endpoints through the Web APIs.
Some of important and widely used actuator endpoints are given below:
|Returns all auto-configuration candidates and the reason why they ‘were’ or ‘were not’ applied.|
|Returns a complete list of all the Spring beans in your application.|
|Displays a collated list of all |
|Returns list of properties in current environment|
|Returns application health information.|
|It exposes available caches.|
|Shows the conditions that were evaluated on configuration and auto-configuration.|
|It displays a collated list of all |
|It shows the Spring Integration graph. Requires a dependency on |
|The configuration of loggers in the application..|
|Displays the scheduled tasks in the application.|
|Returns trace logs (by default the last 100 HTTP requests). Requires an |
|It allows retrieval and deletion of user sessions from a Spring Session-backed session store. Requires a Servlet-based web application using Spring Session.|
|Lets the application be gracefully shutdown. Disabled by default.|
|It performs a thread dump.|
|It shows several useful metrics information like JVM memory used, system CPU usage, open files, and much more.|
The Spring web application (Spring MVC, Spring WebFlux, or Jersey) provide the following additional endpoints:
|Returns an |
|Returns the contents of the logfile if |
1.3. Securing Endpoints
By default, Spring Security is enabled for all actuator endpoints if it available in the classpath.
If you wish to configure custom security for HTTP endpoints, for example, only allow users with a certain role to access then configure
WebSecurityConfigurerAdapter in following manner:
The above configuration ensures that only users with role
ENDPOINT_ADMIN have access to actuation endpoints.
1.4. Enabling Endpoints
By default, all endpoints (except
/shutdown) are enabled. To disable all endpoints, by default, use property:
Then use the only required endpoints which the application need to expose using the pattern
1.5. CORS support
CORS Support is disabled by default and is only enabled once the
endpoints.cors.allowed-origins property has been set.
Here the management context path is
1.6. Caching the Response
Actuator endpoints automatically cache the responses to read operations that do not take any parameters. Use
cache.time-to-live property to configure the amount of time for which an endpoint will cache the response.
2. Spring Boot Actuator Endpoint Example
In this example, we will create a simple spring boot application and access the actuator endpoints to know more about them.
2.1. Development environment
- JDK 1.8, Eclipse, Maven – Development environment
- Spring-boot – Underlying application framework
- Spring-boot Actuator – Management endpoints
2.2. Create Maven Project
Start with creating one spring boot project from Spring Initializer site with
Rest Repositories and
Actuator dependencies. Download project in zipped format. Unzip and then import project in eclipse as maven project.
2.3. Add simple Rest endpoint
Now add one simple Rest endpoint
/example to the application.
3. Spring Boot Actuator Endpoints Demo
I have added
management.security.enabled=false entry to the application.properties file to disable actuator security. Here I am more interested in actuator endpoints responses.
Do maven build using
mvn clean install and start the application using
java -jar target\spring-boot-actuator-example-0.0.1-SNAPSHOT.jar command. This will bring up one tomcat server in default port
8080 and application will be deployed in it.
/example API in browser to generate few monitoring information on server.
- http://localhost:8080/actuator/envThis will give all the environmental configuration about the server.Endpoint env output
- http://localhost:8080/actuator/beansThis will give all the spring beans loaded in the context.Endpoint beans output
- http://localhost:8080/actuator/threaddumpThis will give the current server thread dump.Endpoint threaddump output
Those endpoints will give standard information in the browser. These are the basic important endpoints we generally refer, but spring boot provides many more endpoints as mentioned in this link
4. Actuator Advance Configuration Options
4.1. Change the Management endpoint context path
By default all endpoints comes in default context path of the application, suffixed with
/actuator. If for some reason, we have existing endpoints in application starting with
/actuator then we can customize the base path to something else.
All we need to specify the new base path in the
Now you will be able to access all actuator endpoints under a new URL. e.g.
4.2. Customize the management server port
To customize the management endpoint port, we need to add this entry in the
In this spring boot actuator example, we learned to configure management and monitoring endpoints with few easy configurations. So next time, you need to add application health checks or add monitoring support, you should consider adding the Spring actuator project and use these endpoints.
Feel free to drop your questions in the comments section.
Happy Learning !!