Spring Boot Actuator
Spring Actuator is a set of additional product-ready features that help to monitor, manage and interact with the application. These features are effortless to enable and valuable to use. There is an HTTP endpoint as well as a JMX version available and is used primarily to expose operational information about the application — health, metrics, info, dump, env, etc.
To have access to the application’s operational information for monitoring and management purposes, Spring Boot includes a number of built-in endpoints and lets you add your own. For example, the
health endpoint provides basic application health information. You can enable or disable each endpoint and expose them (make them remotely accessible) over HTTP or JMX. The following table shows the default exposure for the build-in endpoints.
The easiest way to use these features is to add the spring-boot-starter-actuator to your project pom.xml file.
It is highly recommended to disable all endpoints and enable the ones you really need to use and later secure them. By default, only the health endpoint is enabled, and to include or exclude any other endpoints you can use the following pattern:
management.endpoints.jmx.exposure.exclude: exclude the JMX endpoint
management.endpoints.jmx.exposure.include: include JMX endpoint
management.endpoints.web.exposure.exclude: exclude HTTP endpoint
management.endpoints.web.exposure.include: include HTTP endpoint
In the following example, we are enabling all the endpoints except
/beans over HTTP.
Change the Path
Using the following properties you can change the path to the actuator endpoints. by default the value is
If the application exposes to the public you will need to secure these endpoints since they contain sensitive information about your application. Keep in mind that it is highly recommended to not enable any endpoint that you are not using. To secure the endpoints you can start by adding the
The auto-configuration features will take care of securing the endpoint at a basic level. To add a username and password you can begin with setting the following properties in your
In case you need a more flexible security configuration you need to consider extending
WebSecurityConfigurerAdapter or providing
SecurityFilterChain bean for relevant endpoints.
Commonly used Endpoints
The above list is some of the most used Spring Boot Actuator endpoints:
- /health — This endpoint will show details of the health of the application. By default, the only available value is the overall status of the application. but using some extra configuration you can enable more details about the application and the host. you just need to add the following property to your
health.show-details enabled using always property you will get information about the host storage and also related auto-configured HealthIndicators when Spring Boot provides them like dB, JMS, Redis, and…(complete list).
- /metrics — Another useful endpoint is the metrics endpoint which provides a lot of useful information about the application. By calling this endpoint you will get a list of keys that you can use to get more details in the same URL path.
For example to get
/actuator/metrics/application.started.time you will get the application start time.
- /heapdump — Using this endpoint you will be able to download a heap dump snapshot of your running application JVM. This file can be later opened and analyzed using Java VisualVM, IBM HeapAnalyzer, or Eclipse Memory Analyze.
- /threaddump —This endpoint will dump the thread information of the underlying JVM. This information will be returned in JSON format and will include the
threadStatus, and … in any given time.
Each of these endpoints can be helpful in monitoring and managing your application in the production environment. I will be covering the most useful actuator in separate articles in near future.
Hope this article helped you and please support me with your applauding 👏 for the story. if you don’t know how it is just like this:
Or buy me a coffee here!