springcloud的Turbine配置监控多个服务的一些坑!!!!InstanceMonitor$MisconfiguredHostException,No message available","path":"/actuator/hystrix.stream,页面不显示服务或者一直loading

踩了几个小时坑,使用仪表盘监控单个服务的时候很容易,但是一到多个服务,瞬间坑就来了,大概碰到下面三个:

1InstanceMonitor$MisconfiguredHostException, No message available","path":"/actuator/hystrix.stream:

因为我用的是springboot2.0.6版本,这个版本默认路径不是/hystrix.stream,而turbine默认路径是这个,所以要修改一下,可以有两种修改方式:

一: 配置Bean,设置路径

    /**
     * springboot 版本如果是2.0则需要添加 ServletRegistrationBean
     * 因为springboot的默认路径不是 "/hystrix.stream"
     * @return
     */
    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }

  

二: 配置文件配置Bean

页面不显示服务:

这个问题挺坑的,具体原因是因为监控的服务不光要开启熔断和仪表盘,同样也要开启turbine,即启动类需要以下注解,缺一不可:

一直loading:

最后是这个,实际中发现无论怎么访问接口,就是没监控数据,后台测试发现,你所访问的接口必须要有熔断,即普通方法要有fallback:

访问其他方法是不会有监控数据的;

feign接口也要有fallback实现类,才会监控到数据!!!!!!

猜你喜欢

转载自www.cnblogs.com/houzheng/p/9906800.html
今日推荐