(SpringCloud成长笔记(八)Hystrix Dashboard监控看板

SpringCloud成长笔记(八)Hystrix Dashboard监控看板

一、简介

除了之前我们用的zipkin可以监控服务间的调用情况,这里我们再看看Hystrix的Dashboard的效果。

二、环境搭建

上一个工程
在这个工程的基础上进行调整。

三、源码

1、pom.xml的依赖

<!-- 如果提示 Unable to connect to Command Metric Stream. 则需要引入以下包 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<!-- dashboard -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
		</dependency>

2、application.properties中增加配置

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=ALWAYS

之前我们在性能优化的时候已经配置过开启hystrix了

# 在feign中开启hystrix功能,默认情况下feign不开启hystrix功能,开启断路器(把此配置写到 application.yml 中熔断不会生效)
feign.hystrix.enabled=true

微服务的启动类中增加注解

@EnableHystrixDashboard
@EnableHystrix

四、运行

浏览器输入http://localhost:18903/hystrix
如果配置错误,请求http://localhost:18903/hystrix的时候会一直下载Hystrix的文件
在这里插入图片描述
检查配置信息,正确的效果如下
在这里插入图片描述
输入微服务地址
Unable to connect to Command Metric Stream.
在这里插入图片描述
启动类中增加servlet

 @Bean
    public ServletRegistrationBean getServlet(){
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }

这时候路径也发生了改变,需要在monitor里面输入http://localhost:18903/actuator/hystrix.stream
请求http://localhost:18903/test2?name=6,看板如下:
主要是SpringBoot和SpringCloud版本的问题
在这里插入图片描述

五、github源码

Github

六、参考资料

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值