zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    postgresql postgres.Jsonb
    gorm jsonb
    json
    postgresql重置序列和自增主键
    go build x509: certificate has expired or is not yet valid
    权限修饰符
    交换两个变量的值
    Java编译报错:编码GBK的不可映射字符
    原码反码补码的理解
    Scanner类中hasNext()方法的解析
  • 原文地址:https://www.cnblogs.com/wintersoft/p/10027832.html
Copyright © 2011-2022 走看看