spring cloud(Greenwich.M2) hystrix dashboard 报/actuator/hystrix.stream 404 Not Found的问题

consumer端不引用spring-boot-starter-actuator的情况

Consumer端会报Unable to connect to Command Metric Stream。新建HystrixConfiguration类加入以下代码:

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HystrixConfiguration {
    @Bean
    public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet(){
        HystrixMetricsStreamServlet hystrixMetricsStreamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean<HystrixMetricsStreamServlet> servletRegistrationBean = new ServletRegistrationBean();
        servletRegistrationBean.setServlet(hystrixMetricsStreamServlet);
        servletRegistrationBean.addUrlMappings("/hystrix.stream");
        servletRegistrationBean.setName("HystrixMetricsStreamServlet");
        return servletRegistrationBean;
    }
}

hystrix-dashboord输入的地址为http://consumerhost:port/hystrix.stream 

 

turbine站点配置文件加入:

turbine.appConfig=xxx1,xxx2,x3
turbine.instanceUrlSuffix=/hystrix.stream

xxx1为consumer端配置的应用程序名(如spring.application.name=xxx1),通过eareka-server自动找到对应的consumer接口http://consumerhost:port/hystrix.stream去抓取信息显示到turbine聚合界面上。

由于spring-boot-starter-actuator的默认context-path为actuator,若turbine.instanceUrlSuffix不做设置,默认路径为/actuator/hystrix.stream,与我们在consumer中设置的路径/hystrix.stream不匹配,所以出现/actuator/hystrix.stream 404 Not Found。

 

聚合hystrix-dashboord输入的地址为http://consumerhost:port/turbine.stream

 

 

consumer端引用spring-boot-starter-actuator的情况(推荐)

consumer端暴露/actuator/hystrix.stream,/actuator/info,/actuator/health这3个endpoint,配置文件中加入:

management.endpoints.web.exposure.include=hystrix.stream,health,info

 默认值为health,info

 

hystrix-dashboord输入的地址为http://consumerhost:port/actuator/hystrix.stream 

 

turbine站点配置文件加入:

turbine.appConfig=xxx1,xxx2,xxx3
turbine.instanceUrlSuffix=/actuator/hystrix.stream

/actuator/hystrix.stream为默认地址也可以不写。

 聚合hystrix-dashboord输入的地址为http://consumerhost:port/turbine.stream

 

转载于:https://www.cnblogs.com/wintersoft/p/10027832.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值