通过Springboot - Actuator进行健康监控
pom.xml配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
application.properties
server.port=8091
#management.port=8092
#spring.datasource.url=jdbc:mysql://localhost:3306/user?characterEncoding=UTF-8
#spring.datasource.username=root
#spring.datasource.password=123456
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.druid.driverClassName=com.mysql.jdbc.Driver
spring.druid.url=jdbc:mysql://127.0.0.1:3306/houses?useUnicode=true&amp;characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull
spring.druid.username=root
spring.druid.password=888888
#druid\u75311.0.16\u5347\u7ea7\u52301.1.0,\u8fde\u63a5\u6c60\u914d\u7f6e\u8981\u6539\u6210maxActive,minIdle
spring.druid.maxActive=30
spring.druid.minIdle=5
spring.druid.maxWait=10000
spring.druid.validationQuery=SELECT 'x'
mybatis.config-location=classpath:/mybatis/mybatis-config.xml
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html;charset=UTF-8
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.expose-spring-macro-helpers=true
spring.freemarker.suffix=.ftl
spring.freemarker.settings.datetime_format=yyyy-MM-dd HH:mm:ss
spring.freemarker.settings.default_encoding=UTF-8
spring.freemarker.settings.auto_import=common/common.ftl as common
#\u672c\u5730\u5b58\u653e\u7684\u6587\u4ef6\u8def\u5f84,\u53ef\u4ee5\u4fee\u6539\u6210\u81ea\u5df1\u7684\u56fe\u7247\u5b58\u653e\u8def\u5f84,\u5bf9\u5e94nginx.conf\u91ccalias\u5bf9\u5e94\u76ee\u5f55(\u82e5\u672c\u5730\u5b89\u88c5\u4e86nginx\u670d\u52a1\u5668,\u5f00\u542f\u5982\u4e0b\u914d\u7f6e)
file.path=/Users/wangjialuo/opt/imgs
#\u9759\u6001\u8d44\u6e90\u5730\u5740\u524d\u7f00(\u82e5\u672c\u5730\u5b89\u88c5\u4e86nginx\u670d\u52a1\u5668,\u5f00\u542f\u5982\u4e0b\u914d\u7f6e)
file.prefix=http://127.0.0.1:8081/images
#\u9759\u6001\u8d44\u6e90\u5730\u5740\u524d\u7f00(\u82e5\u672a\u5b89\u88c5nginx\u60f3\u5feb\u901f\u770b\u6548\u679c,\u5f00\u542f\u5982\u4e0b\u914d\u7f6e\uff09
#file.prefix=http://127.0.0.1:8091/static/imgs
#SpringBoot Admin\u76d1\u63a7\u5730\u5740
spring.boot.admin.url=http://localhost:8070
domain.name=127.0.0.1:8091
#邮箱配置
spring.mail.host=smtp.163.com
spring.mail.username=spring_boot@163.com
spring.mail.password=abc123455
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.output.ansi.enabled=always
说明:
1)server.port=8091
2)management.port=8092添加这个可以让监控URL和应用程序分开;
各个监控和管理端点
1.actuator
所有EndPoint的列表,需加入spring HATEOAS支持 http://shangwu:8091/actuator/
2.beans
当前应用中所有bean的信息 http://shangwu:8091/beans
3.configprops
当前应用中所有的配置属性 http://shangwu:8091/configprops
4.dump
显示当前应用线程状态信息 有heapdump、threaddump
5.env
显示当前应用当前环境信息 http://shangwu:8091/env
6.health
健康状况 http://shangwu:8091/health
7.info
当前应用信息 http://shangwu:8091/info
8.metrics
各项指标信息 http://shangwu:8091/metrics
9.mappings
显示所有所有@mapping映射的路径 http://shangwu:8091/mappings
10.httptrace
显示追踪信息(默认最新的http请求)
==============================
QQ群:143522604
群里有相关资源
欢迎和大家一起学习、交流、提升!
==============================