Hystrix Dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间,请求成功率等数据。
前提:服务提供者、消费者均需要引入actuator包,需要引入Hystrix熔断,主类增加启动熔断注解EnableCircuitBreaker

服务提供者

HystrixConfig.java

@Configuration
public class HystrixConfig {	
	// 解决spring boot 2.0如下提示的问题
	// Unable to connect to Command Metric Stream
	@Bean
	public ServletRegistrationBean getHystrixBean() {
		ServletRegistrationBean hystrix = new ServletRegistrationBean(
				new HystrixMetricsStreamServlet(), "/hystrix.stream");
		hystrix.setName("hystrixServlet");
		hystrix.setLoadOnStartup(1);
		return hystrix;
	}
}

服务消费者

HystrixConfig.java 同上

服务注册中心

pom.xml

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

CloudApplication.java 启用Hystrix Dashboard注解

@SpringBootApplication
@EnableEurekaServer
@EnableHystrixDashboard
public class CloudApplication {
	public static void main(String[] args) {
		SpringApplication.run(CloudApplication.class, args);
	}
}

测试
hystrix 监控地址http://cos6743:9000/hystrix
Spring Cloud引入Hystrix Dashboard监控工具
主界面中输入http://cos6743:8081/hystrix.stream或http://cos6743:8082/hystrix.stream
但需要模拟调用接口,否则一直是loading
Spring Cloud引入Hystrix Dashboard监控工具
Spring Cloud引入Hystrix Dashboard监控工具

相关文章:

  • 2021-10-07
  • 2021-10-14
  • 2021-12-07
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-04-29
  • 2022-12-23
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2021-10-21
  • 2021-05-28
  • 2021-11-21
  • 2019-12-13
  • 2021-09-19
相关资源
相似解决方案