无法连接到 Hystrix 仪表板中的命令指标流

Unable to connect to Command Metric Stream in hystrix dashboard

我正在尝试使用 Netflix eureka 服务发现和 hystrix 断路器构建简单的 spring 云应用程序。

断路器服务:

@EnableCircuitBreaker
@SpringBootApplication
@EnableEurekaClient
public class PluralsightEurekaFastpassConsoleApplication {

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

pom.xml

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>
                spring-cloud-starter-netflix-hystrix
            </artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

Hystrix 仪表板

@EnableHystrixDashboard
@SpringBootApplication
@EnableDiscoveryClient
public class PluralsiteHystrixDashboardApplication {

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

pom.xml

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

hystrix 仪表板

控制台日志

2018-07-04 20:15:25.051 INFO 17516 --- [nio-8088-exec-1] ashboardConfiguration$ProxyStreamServlet : Proxy opening connection to: http://localhost:8088/actuator/hystrix.stream 2018-07-04 20:15:25.052 INFO 17516 --- [nio-8088-exec-6] ashboardConfiguration$ProxyStreamServlet : Proxy opening connection to: http://localhost:8088/actuator/hystrix.stream 2018-07-04 20:15:25.058 WARN 17516 --- [nio-8088-exec-1] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:8088/actuator/hystrix.stream : 404 : HTTP/1.1 404 2018-07-04 20:15:25.058 WARN 17516 --- [nio-8088-exec-6] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:8088/actuator/hystrix.stream : 404 : HTTP/1.1 404

我试过无法使用 Spring 云连接到 Hystrix 仪表板的命令指标流

但问题依然存在。

这个问题没有提供足够的信息,所以最好的办法可能是确保:

  1. 断路器服务 运行 在端口 8088
  2. 断路器服务中的 spring 个引导执行器端点确实已部署并可在 actuator 上下文路径下访问。为了检查执行器实际在哪里,分析启动日志,如果没有部署端点的信息,则在微服务的应用程序启动中添加--debug

看来第二步会暴露真正的问题。 然后可以使用 management.context-path 设置执行器上下文路径,或者应该自定义 hystix 仪表板