<dependency><!--监控依赖--><!--http://localhost:8030/hystrix.stream--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
在xcservice-eureka-user-hystrix工程的pom.xml中引入上述依赖后,即可查看监控信息,具体操作步骤如下。
ping:
data: {"type":"HystrixCommand","name":"findOrdersByUser","group":"UserController","currentTime":1563192973047,"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_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":"UserController"}
data: {"type":"HystrixThreadPool","name":"UserController","currentTime":1563192973047,"currentActiveCount":0,"currentCompletedTaskCount":6,"currentCorePoolSize":10,"currentLargestPoolSize":6,"currentMaximumPoolSize":10,"currentPoolSize":6,"currentQueueSize":0,"currentTaskCount":6,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1}
<?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"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.xc</groupId> <artifactId>xcservice-springcloud</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>com.xc</groupId> <artifactId>xcservice-hystrix-dashboard</artifactId> <version>0.0.1-SNAPSHOT</version> <name>xcservice-hystrix-dashboard</name> <description>Hystrix Dashboard是Hystrix的一个组件,它提供了数据监控和友好的图形化界面支持。</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency><!--数据监控和友好的图形化界面支持--><!--http://localhost:8031/hystrix.stream--> <groupId>org.springframework.cloud</groupId> <artifactId> spring-cloud-starter-hystrix-dashboard</artifactId> </dependency> <dependency><!--监控依赖--><!--http://localhost:8030/hystrix.stream--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
(2)编写配置文件application.yml,指定应用的端口号和名称等信息,如文件5-6所示。
server:
port: 8031 # 指定该Eureka实例的端口号
spring:
application:
name: xcservice-hystrix-dashboard # 指定应用名称
(3)编写启动类Application.java,并在其类上添加@EnableHystrixDashboard注解来开启Hystrix仪表板功能,如文件5-7所示。
package com.xc.xcservicehystrixdashboard; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; @SpringBootApplication @EnableHystrixDashboard public class XcserviceHystrixDashboardApplication { public static void main(String[] args) { SpringApplication.run(XcserviceHystrixDashboardApplication.class, args); } }
(4)启动工程后,通过浏览器访问地址http://local-host:8031/hystrix.stream将会看到如图5-8所示的信息。
关于图中各个指标的含义,在Hystrix Dashboard Wiki上已经给出了详细说明,读者可访问地址https://github.com/Netflix/Hystrix/wiki/Dashboard查看。
Spring Cloud Hystrix Dashboard的使用 5.1.3
原文:https://www.cnblogs.com/ooo0/p/11191394.html