Explain the configuration and use of spring boot actuator in detail

In a production environment, the availability of services needs to be monitored in real time or on a regular basis. The actuator function of spring boot provides many interfaces required for monitoring. Simple configuration and use are as follows:

1. Import dependency:

This dependency is also required if HTTP calls are used:

2. Configuration:

application. Specify the HTTP port to monitor in YML (if not specified, use the same port as the server); specify the check to remove an item (such as not monitoring health. Mail):

3. Use:

To view health indicators: http://localhost:54001/health

4. Custom indicator:

4.1 / health: implement the healthindicator interface in a class, and then implement the health () method in it:

code:

/Health running results (note the second indicator):

{"status":"UP","mySpringBootApplication":{"status":"UP","hello":"world"},"hello":1}}}

4.2 / INFO: the configuration is as follows. You can give a string directly or from POM Get from XML configuration

/The results of info are as follows:

{"app":{"name":"my-spring-boot","description":"Test Project for Spring Boot","version":"1.0","spring-boot-version":"1.3.6.RELEASE"}}

Official website: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production -ready

Source code reference: https://github.com/xujijun/my-spring-boot

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>