Spring Cloud引入Hystrix Dashboard监控工具

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
hystrix
主界面中输入http://cos6743:8081/hystrix.stream或http://cos6743:8082/hystrix.stream
但需要模拟调用接口,否则一直是loading
hello
feign

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值