监控管理依赖:implementation 'org.springframework.boot:spring-boot-starter-actuator'
默认情况下监控根路径为:http://ip:port/actuator,port默认取server.port
下面说一下自定义监控路径和端口的方法:(下面只贴出部分关键配置,其他配置参考别的地方的资料)
微服务中添加如下配置:application.yml:
management:
server:
#自定义监控端口
port: ${CONFIG_SERVICE_MGR_PORT:9009}
# servlet:
#设置健康监控的servlet路径,该配置需要配合management.server.servlet.port才起效
#不设置默认使用server.servlet.context-path
# context-path: /ctx
endpoints:
web:
#默认/actuator, 自定义为/monitor
base-path: /monitor
exposure:
include: '*'
#允许跨域请求,支持GET/POST
cors:
allowed-origins: http://hello.com
allowed-method: GET,POST
endpoint:
#允许调用shutdown停止监控进程
shutdown:
enabled: true
#启用健康检查
health:
enabled: true
show-details: when-authorized
health:
#启用默认的所有默认的健康检查indicator(指标)
# defaults:
# enable: true