Hystrix 不显示仪表板

Posted

技术标签:

【中文标题】Hystrix 不显示仪表板【英文标题】:Hystrix not showing dashboard 【发布时间】:2020-10-01 18:13:44 【问题描述】:

这就是我的 pom.xml 的样子

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>SalaryBox</artifactId>
        <groupId>org.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.salary.box</groupId>
    <artifactId>greeting-service</artifactId>
    <packaging>war</packaging>

    <properties>
        <spring-cloud.version>Hoxton.SR5</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</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>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

</project>

这就是我的主类的样子

@SpringBootApplication @EnableDiscoveryClient @EnableFeignClients @EnableCircuitBreaker @EnableHystrixDashboard 公共类应用程序 公共静态 void main(String[] args) SpringApplication.run(Application.class, args);

这就是我的应用程序属性的样子

spring.application.name=问候服务 service.message-service.id=消息服务 management.endpoints.web.exposure.include=*

这就是我的控制器的样子

@RestController 公共类 GreetingController

@Autowired
public GreetingsService greetingsService;

@HystrixCommand(fallbackMethod = "defaultMessage")
@RequestMapping("/greeting/id")
public Greeting findMyGreetingMessage(@PathVariable Long id) 
    Greeting greeting = new Greeting();
    greeting.setMessage(greetingsService.getMessage(id));
    return greeting;


public Greeting defaultMessage(Long id)
    Greeting greeting = new Greeting();
    greeting.setMessage("Message service seems to be broken");
    return greeting;

当我检查 URL http://localhost:8082/actuator/hystrix.stream 时,流似乎生成如下

数据:"type":"HystrixCommand","name":"findMyGreetingMessage","group":"GreetingController","currentTime":1591920892870,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount ":0,"requestCount":0,"rollingCountBadRequests":0,"rollingCountCollapsedRequests":0,"rollingCountEmit":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackEmit":0,"rollingCountFallbackFailure": 0,"rollingCountFallbackMissing":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0, "rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"rollingMaxConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":"0":0,"25":0,"50":0,"75" :0,"90":0,"95":0,"99":0,"99.5":0,"100":0,"latencyTotal_mean":0,"latencyTotal":"0":0 ,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0, “propertyValue_circuitBreake rRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD_","InpropertyValueIillisexec":"THREAD_Thread","InM propertyValue_executionTimeoutInMilliseconds “:1000,” propertyValue_executionIsolationThreadInterruptOnTimeout “:真实的,” propertyValue_executionIsolationThreadPoolKeyOverride “:空,” propertyValue_executionIsolationSemaphoreMaxConcurrentRequests “:10,” propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests “:10,” propertyValue_metricsRollingStatisticalWindowInMilliseconds “:10000,” propertyValue_requestCacheEnabled “:真实的,” propertyValue_requestLogEnabled “:真实的,” reportingHosts” :1,"threadPool":"GreetingController"

数据:"type":"HystrixThreadPool","name":"GreetingController","currentTime":1591920892870,"currentActiveCount":0,"currentCompletedTaskCount":2,"currentCorePoolSize":10,"currentLargestPoolSize": 2,"currentMaximumPoolSize":10,"currentPoolSize":2,"currentQueueSize":0,"currentTaskCount":2,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5, "propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1

平:

数据:"type":"HystrixCommand","name":"findMyGreetingMessage","group":"GreetingController","currentTime":1591920893373,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount ":0,"requestCount":0,"rollingCountBadRequests":0,"rollingCountCollapsedRequests":0,"rollingCountEmit":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackEmit":0,"rollingCountFallbackFailure": 0,"rollingCountFallbackMissing":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0, "rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"rollingMaxConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":"0":0,"25":0,"50":0,"75" :0,"90":0,"95":0,"99":0,"99.5":0,"100":0,"latencyTotal_mean":0,"latencyTotal":"0":0 ,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0, “propertyValue_circuitBreake rRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD_","InpropertyValueIillisexec":"THREAD_Thread","InM propertyValue_executionTimeoutInMilliseconds “:1000,” propertyValue_executionIsolationThreadInterruptOnTimeout “:真实的,” propertyValue_executionIsolationThreadPoolKeyOverride “:空,” propertyValue_executionIsolationSemaphoreMaxConcurrentRequests “:10,” propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests “:10,” propertyValue_metricsRollingStatisticalWindowInMilliseconds “:10000,” propertyValue_requestCacheEnabled “:真实的,” propertyValue_requestLogEnabled “:真实的,” reportingHosts” :1,"threadPool":"GreetingController"

数据:"type":"HystrixThreadPool","name":"GreetingController","currentTime":1591920893373,"currentActiveCount":0,"currentCompletedTaskCount":2,"currentCorePoolSize":10,"currentLargestPoolSize": 2,"currentMaximumPoolSize":10,"currentPoolSize":2,"currentQueueSize":0,"currentTaskCount":2,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5, "propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1

平:

但是,即使在多次刷新并尝试多次点击 url 之后,仪表板似乎仍然卡在这一点上。

我错过了什么?

【问题讨论】:

【参考方案1】:

尝试添加proxyStreamAllowList,在application.properties中添加这个-

hystrix.dashboard.proxyStreamAllowList = "*"

这个帖子看起来很相似 - Unable to connect to Command Metric Stream. in Hystrix Dashboard issue

【讨论】:

以上是关于Hystrix 不显示仪表板的主要内容,如果未能解决你的问题,请参考以下文章

Hystrix 仪表板总是显示加载屏幕

如何在仪表板中查看 Hystrix 指标的天数以进行监控

hystrix 仪表板不加载

Hystrix 仪表板

Spring Cloud Turbine AMQP 不适用于 Hystrix 仪表板

Spring Cloud Hystrix 仪表板不与 OAuth 一起使用