spring boot2.x之后不提供hystrix.stream节点处理方法

spring boot2.x之后不提供hystrix.stream节点处理方法

作为springBoot2.x以后不在提供hystrix.stream节点,导致hystrix数据监控无法返回数据,从而使返回的页面为404,在这里有两种解决方法。

1、在被监控的服务启动类中或者添加一个配置类,来添加hystrix.stream节点

注意:此配置的访问地址为

http://服务ip地址:端口/hystrix.stream

(1)添加配置类

@Configuration
public class ConfigBean {

    @Bean
    public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet() {
        HystrixMetricsStreamServlet servlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean<HystrixMetricsStreamServlet> bean = new ServletRegistrationBean<>(servlet);
        bean.addUrlMappings("/hystrix.stream");
        bean.setName("HystrixMetricsStreamServlet");
        return bean;
    }
}

(2)在启动类中添加以下代码,添加hystrix.stream节点

@SpringBootApplication
@EnableZuulProxy    //开启网关服务zuul
public class ZuulApplication {

    public static void main(String[] args) {
        SpringApplication.run(ZuulApplication.class, args);
    }

    @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;
    }
}
2、在被监控的服务中的全局配置文件中,添加hystrix.stream节点

注意:此配置的访问地址为

http://服务ip地址:端口/actuator/hystrix.stream

在全局配置文件在加入以下配置:

#暴露shutdown,hystrix.stream端点服务
management.endpoints.web.exposure.include=shutdown,hystrix.stream
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值