如何访问Hystrix仪表板?

时间:2019-11-11 18:58:24

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

我在Spring Boot应用程序中添加了以下依赖项:

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

并用:标记配置类:

@EnableHystrixDashboard
@EnableHystrix

我尝试访问http://localhost:8080/hystrix(我也尝试过http://localhost:8081/hystrix

我看到:

  

Whitelabel错误页面此应用程序没有针对   /错误,因此您将其视为备用。

     

Mon Nov 11 21:47:56 MSK 2019发生意外错误(type = Not   找到,状态为404)。没有可用消息

在启动过程中,我看到以下消息:

2019-11-11 21:43:17.724  INFO 15912 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-11-11 21:43:22.581  INFO 15912 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-11-11 21:43:23.362  INFO 15912 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2019-11-11 21:43:23.507  INFO 15912 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''

如何访问hystrix仪表板?

P.S。

在调试中,我看到这些方法已被调用,但无论如何我都看到错误:

enter image description here

当我访问URL时,我还会看到以下响应:http://localhost:8080/actuator/hystrix.stream

data: {"type":"HystrixCommand","name":"executeHttpCall","group":"MyAPIConnectorImpl","currentTime":1573503001364,"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":948,"latencyExecute":{"0":16,"25":18,"50":23,"75":1008,"90":3767,"95":3767,"99":3767,"99.5":3767,"100":3767},"latencyTotal_mean":950,"latencyTotal":{"0":16,"25":18,"50":24,"75":1019,"90":3767,"95":3767,"99":3767,"99.5":3767,"100":3767},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1,"threadPool":"MyAPIConnectorImpl"}

data: {"type":"HystrixThreadPool","name":"MyAPIConnectorImpl","currentTime":1573503001364,"currentActiveCount":0,"currentCompletedTaskCount":18,"currentCorePoolSize":10,"currentLargestPoolSize":10,"currentMaximumPoolSize":10,"currentPoolSize":10,"currentQueueSize":0,"currentTaskCount":18,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1}

ping:

在调试日志中,我看到:

2019-11-11 23:41:28.436 DEBUG 6604 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : GET "/hystrix/index", parameters={}
2019-11-11 23:41:28.447 DEBUG 6604 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardController#monitor(String, Model, WebRequest)
2019-11-11 23:41:28.480 DEBUG 6604 --- [nio-8080-exec-1] o.s.ui.freemarker.SpringTemplateLoader   : Looking for FreeMarker template with name [hystrix/index_ru_RU.ftlh]
2019-11-11 23:41:28.482 DEBUG 6604 --- [nio-8080-exec-1] o.s.ui.freemarker.SpringTemplateLoader   : Looking for FreeMarker template with name [hystrix/index_ru.ftlh]
2019-11-11 23:41:28.482 DEBUG 6604 --- [nio-8080-exec-1] o.s.ui.freemarker.SpringTemplateLoader   : Looking for FreeMarker template with name [hystrix/index.ftlh]
2019-11-11 23:41:28.485 DEBUG 6604 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/webp, image/apng, application/signed-exchange;v=b3, application/xml;q=0.9, */*;q=0.8]
2019-11-11 23:41:28.485 DEBUG 6604 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : View name 'hystrix/index', model {basePath=/hystrix/index, contextPath=}
2019-11-11 23:41:28.487 DEBUG 6604 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView  : Forwarding to [hystrix/index]
2019-11-11 23:41:28.491 DEBUG 6604 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : "FORWARD" dispatch for GET "/hystrix/hystrix/index", parameters={}
2019-11-11 23:41:28.494 DEBUG 6604 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2019-11-11 23:41:28.497 DEBUG 6604 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2019-11-11 23:41:28.498 DEBUG 6604 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Exiting from "FORWARD" dispatch, status 404
2019-11-11 23:41:28.499 DEBUG 6604 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2019-11-11 23:41:28.502 DEBUG 6604 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : "ERROR" dispatch for GET "/error", parameters={}
2019-11-11 23:41:28.503 DEBUG 6604 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2019-11-11 23:41:28.513 DEBUG 6604 --- [nio-8080-exec-1] o.s.ui.freemarker.SpringTemplateLoader   : Looking for FreeMarker template with name [error_ru_RU.ftlh]
2019-11-11 23:41:28.514 DEBUG 6604 --- [nio-8080-exec-1] o.s.ui.freemarker.SpringTemplateLoader   : Looking for FreeMarker template with name [error_ru.ftlh]
2019-11-11 23:41:28.514 DEBUG 6604 --- [nio-8080-exec-1] o.s.ui.freemarker.SpringTemplateLoader   : Looking for FreeMarker template with name [error.ftlh]
2019-11-11 23:41:28.515 DEBUG 6604 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2019-11-11 23:41:28.519 DEBUG 6604 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Exiting from "ERROR" dispatch, status 404

3 个答案:

答案 0 :(得分:0)

Hystrix搜索@HystrixCommand批注以显示有关您要监视的服务的数据,并且它需要执行器端点。 您将需要这三个依赖项:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

然后尝试输入网址http://localhost:8080/hystrix。看到hystrix dasboard ui后,您应该输入流的URL(在本例中为http://localhost:8080/actuator/hystrix.stream)。最后,您将能够查看一些数据。

答案 1 :(得分:0)

尝试更改版本,对我来说有用。    -弹簧靴:2.2.2.RELEASE    -春天的云:Hoxton.RELEASE(格林尼治。RELEASE不起作用)

答案 2 :(得分:0)

我遇到了相同的问题,可以通过以下步骤解决

  1. 在SpringBootApplication中添加以下注释-存在main方法的地方

    @EnableHystrixDashboard

    @EnableHystrix

  2. 在pom.xml中

    org.springframework.cloud Spring-Cloud-NetFlix-Hystrix-仪表板

    org.springframework.boot 弹簧启动启动器执行器

pom.xml

  1. 在application.properties中

    management.endpoints.web.exposure.include = hystrix.stream

  2. 点击网址

    http://localhost:8081/hystrix

您应该能够看到Hystrix仪表板