[英]How to access hystrix dashboard?
我在 spring 引導應用程序中添加了以下依賴項:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
並標注配置 class 與:
@EnableHystrixDashboard
@EnableHystrix
我嘗試訪問http://localhost:8080/hystrix
(我也嘗試過http://localhost:8081/hystrix
)
我看到了:
Whitelabel 錯誤頁面 此應用程序沒有針對 /error 的顯式映射,因此您將其視為后備。
2019 年 11 月 11 日星期一 21:47:56 MSK 出現意外錯誤(類型=未找到,狀態=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 儀表板?
在調試中,我看到調用了這些方法,但無論如何我看到錯誤:
當我訪問 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
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>
然后嘗試輸入 url http://localhost:8080/hystrix 。 看到 hystrix 儀表板 ui 后,您應該在您的案例中輸入流的 url 即http://localhost:8080/actuator/hystrix.ZF7B44CFAFD5C52223D7BZA821 。 最后,您將能夠查看一些數據。
我不知道您使用的是哪個 spring-boot 版本,因為您應該考慮 spring-boot 和 spring-cloud 之間的兼容性。 如果您的 spring-boot 版本是 2.2.2.RELEASE,嘗試將 hystrix-dashboard 版本更改為 2.2.0.RELEASE。 如果沒有,請在https://spring.io/projects/spring-cloud中查找發布序列
推薦使用依賴管理工具來控制版本。如下所示:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<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.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-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</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>
我遇到了同樣的問題,使用以下步驟解決了
將以下注釋添加到 SpringBootApplication -- 存在 main 方法的地方
@EnableHystrix儀表板
@EnableHystrix
在 pom.xml
org.springframework.cloud spring-cloud-netflix-hystrix-dashboard
org.springframework.boot spring-boot-starter-actuator
在 application.properties
management.endpoints.web.exposure.include=hystrix.stream
打URL
你應該可以看到 Hystrix Dashboard
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.