springboot 2.0 运行状态监控使用 Actuator

  springboot的Actuator提供了运行状态监控的功能,可以通过REST、远程Shell和JMX方式来查看。
  
  使用时倒入spring-boot-starter-actuator的依赖即可。
  这里说下springboot2.0的配置方法,因为springboot2开始配置项与之前有了些差别:
  这里写图片描述
  之前的配置项为:
  

management.port=9001
management.security.enabled=false

这两个属性可以发现已经改变了。

springboot2.0 的配置项为:

#actuator端口 
management.server.port=9001
#修改访问路径  2.0之前默认是/   2.0默认是 /actuator  可以通过这个属性值修改  
management.endpoints.web.base-path=/monitor
#开放所有页面节点  默认只开启了health、info两个节点
management.endpoints.web.exposure.include=*
#显示健康具体信息  默认不会显示详细信息  
management.endpoint.health.show-details=always

配置完成启动项目后就可以通过postman或者直接在预览器输入路径等方式来查看应用的运行状态了。

例如使用postman发送 localhost:9001/monitor/health GET请求 (除了shutdown请求为post,其他的皆为GET请求)
这里写图片描述
可以看到redis没有连接成功。

Actuator的api接口:
actuator API这里写图片描述

health的健康指示器:
这里写图片描述

官方文档地址:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

猜你喜欢

转载自blog.csdn.net/qq_36666651/article/details/80696810
今日推荐