【问题标题】:Unable to connect to Command Metric Stream in hystrix dashboard无法连接到 hystrix 仪表板中的命令度量流
【发布时间】: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

但问题依然存在。

【问题讨论】:

    标签: java spring-boot spring-cloud-netflix hystrix


    【解决方案1】:

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

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

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

    【讨论】:

    • 谢谢马克,是的,执行器上下文路径中的问题。通过在 application.properties 中设置 [management.endpoints.web.exposure.include=hystrix.stream] 并通过 [localhost:8081/actuator/hystrix.stream] 访问 hystrix 流来解决
    猜你喜欢
    • 2017-05-09
    • 2020-05-01
    • 2017-01-30
    • 1970-01-01
    • 2018-05-08
    • 2018-06-24
    • 2020-09-15
    • 2015-10-06
    • 2023-03-12
    相关资源
    最近更新 更多