无法连接到 hystrix 仪表板中的命令度量流

Posted

技术标签:

【中文标题】无法连接到 hystrix 仪表板中的命令度量流【英文标题】:Unable to connect to Command Metric Stream in hystrix dashboard 【发布时间】:2018-12-13 03:13:41 【问题描述】:

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

断路器服务:

@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 信息 17516 --- [nio-8088-exec-1] ashboardConfiguration$ProxyStreamServlet : 代理打开连接 致:http://localhost:8088/actuator/hystrix.stream2018-07-04 20:15:25.052 信息 17516 --- [nio-8088-exec-6] ashboardConfiguration$ProxyStreamServlet : 代理打开连接 至:http://localhost:8088/actuator/hystrix.stream2018-07-04 20:15:25.058 警告 17516 --- [nio-8088-exec-1] ashboardConfiguration$ProxyStreamServlet:打开连接失败 到http://localhost:8088/actuator/hystrix.stream:404:HTTP/1.1 404 2018-07-04 20:15:25.058 警告 17516 --- [nio-8088-exec-6] ashboardConfiguration$ProxyStreamServlet:打开连接失败 到http://localhost:8088/actuator/hystrix.stream:404:HTTP/1.1 404

我试过Unable to connect to Command Metric Stream for Hystrix Dashboard with Spring Cloud

但问题依然存在。

【问题讨论】:

【参考方案1】:

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

    断路器服务正在端口 8088 上运行 断路器服务中的弹簧启动执行器端点确实在actuator 上下文路径下部署和访问。为了检查actuator实际在哪里,分析启动日志,如果没有部署端点的信息,则在微服务的应用启动中添加--debug

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

【讨论】:

谢谢马克,是的,执行器上下文路径中的问题。通过在 application.properties 中设置 [management.endpoints.web.exposure.include=hystrix.stream] 并通过 [localhost:8081/actuator/hystrix.stream] 访问 hystrix 流来解决

以上是关于无法连接到 hystrix 仪表板中的命令度量流的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot 中的 Hystrix 仪表板问题

无法使用 Spring Cloud 连接到 Hystrix Dashboard 的 Command Metric Stream

带有 docker-compose 的解析仪表板:无法连接到服务器

无法在 Hystrix 仪表板上查看 Hystrix 报告

Tableau Desktop 日常问题 5.0打开第二个 Tableau 桌面实例时出现错误“连接错误:Tableau 无法连接到数据源“

无法在 Spring Boot 应用程序中设置 hystrix 仪表板