Springboot admin监控不到context-path服务

写在前面:前段时间给同事解决Springboot admin监控异常问题,发现网上关于此类问题多是基于Eureka注册中心,关于consul所述甚少,特写此贴。

背景:微服务A是一个springboot服务,该服务接入consul注册中心,并设置了context-path。

最近,我们在做基于Springboot admin的微服务告警,在集成admin监控时发现设置了congtext-path的服务无法监控,经排查发现admin监控地址未包含context-path导致。

通过排查源码发现InstanceDiscoveryListener中registerInstance对象中有三个重要的地址信息,通过debug源码发现该地址通过注册中心元数据拼接,具体代码不贴图了,下面说下我的解决方案。

针对consul注册中心,请在consul配置中添加如下:

#支持springboot admin监控基于context-path的springboot应用
spring.cloud.consul.discovery.tags[1]=management.context-path=/${spring.application.name}/actuator

consul解决思路参考了Eureka解决思路,链接地址:https://blog.csdn.net/hubo_88/article/details/80684339?utm_source=blogxgwz8

猜你喜欢

转载自blog.csdn.net/weixin_39195030/article/details/112472944