Mastering Spring Cloud
上QQ阅读APP看书,第一时间看更新

Spring Boot Actuator features

Just creating the working application and sharing standardized API documentation is not everything, especially if we are talking about microservices, where there are plenty of independent entities structuring one managed environment. The next important thing that needs to be mentioned is monitoring and gathering metrics from applications. In that aspect, Spring Boot also comes through. Project Spring Boot Actuator provides a number of built-in endpoints, which allow us to monitor and interact with the application. To enable it in our project, we should include spring-boot-starter-actuator in the dependencies. Here's a list of the most important Actuator endpoints:

Path Description
/beans Displays a full list of all the Spring beans initialized in the application.
/env Exposes properties from Spring’s Configurable Environment, which means, for example, OS environment variables and properties from configuration files.
/health Shows application health information.
/info Displays arbitrary application information. It can be taken, for example, from the build-info.properties or git.properties files.
/loggers Shows and modifies the configuration of loggers in the application.
/metrics Shows metrics information for the current application, such as memory usage, number of running threads, or REST method response time.
/trace Displays trace information (by default the last 100 HTTP requests).

 

Endpoints can be easily customized using Spring configuration properties. For example, we can disable one of the enabled by default endpoints. By default, all endpoints except for shutdown are enabled. Most of these endpoints are secured. If you would like to call them from your web browser, you should provide security credentials in the request header or disable security for the whole project. To do the latter, you have to include the following statement in your application.yml file:

management:
security:
enabled: false