首页 文章

无法连接到hystrix仪表板中的Command Metric Stream

提问于
浏览
0

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

Circuit Breaker Service:

@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 Dashboard

@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 dashboard
hystrix-dashboard

Console Log

2018-07-04 20:15:25.051 INFO 17516 --- [nio-8088-exec-1] ashboardConfiguration $ ProxyStreamServlet:代理打开连接:http:// localhost:8088 / actuator / hystrix.stream 2018-07 -04 20:15:25.052 INFO 17516 --- [nio-8088-exec-6] ashboardConfiguration $ ProxyStreamServlet:代理打开连接到:http:// localhost:8088 / actuator / hystrix.stream 2018-07-04 20: 15:25.058 WARN 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 WARN 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 回答

  • 3

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

    • Circuit Breaker Service 正在端口8088上运行

    • 断路器服务中的 spring 启动 Actuator endpoints 确实已在 actuator 上下文路径下部署和访问 . 为了检查 Actuator 的实际位置,分析启动日志,如果没有关于已部署 endpoints 的信息,请将 --debug 添加到微服务的应用程序启动中 .

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

相关问题