码迷,mamicode.com
首页 > 编程语言 > 详细

springcloud(五):熔断监控Hystrix Dashboard

时间:2018-11-28 12:35:32      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:请求   tap   clu   ESS   size   说明   架构   ati   ...   

Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine.愿意了解源码的朋友直接求求交流分享技术:二一四七七七五六三三

Hystrix Dashboard
我们在熔断示例项目spring-cloud-consumer-hystrix的基础上更改,重新命名为:spring-cloud-consumer-hystrix-dashboard。

1、添加依赖

<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>

这三个包必须添加

2、启动类
启动类添加启用Hystrix Dashboard和熔断器

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrixDashboard
@EnableCircuitBreaker
public class ConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }
}

3、测试
启动工程后访问 http: //localhost:9001/hystrix,将会看到如下界面:

技术分享图片

图中会有一些提示:

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream?
Cluster via Turbine (custom cluster): http://turbine-hostname:port/turbine.stream?cluster=[clusterName]
Single Hystrix App: http://hystrix-app:port/hystrix.stream

大概意思就是如果查看默认集群使用第一个url,查看指定集群使用第二个url,单个应用的监控使用最后一个,我们暂时只演示单个应用的所以在输入框中输入: http:/ /localhost:9001/hystrix.stream ,输入之后点击 monitor,进入页面。

如果没有请求会先显示Loading ...,访问http:// localhost:9001/hystrix.stream 也会不断的显示ping。

请求服务http:/ /localhost:9001/hello/neo,就可以看到监控的效果了,首先访问http: //localhost:9001/hystrix.stream,显示如下:

ping:

data: {"type":...}

data: {"type":...}
说明已经返回了监控的各项结果

到监控页面就会显示如下图:
技术分享图片

其实就是http://localhost:9001/hystrix.stream返回结果的图形化显示,Hystrix Dashboard Wiki上详细说明了图上每个指标的含义,如下图:

技术分享图片

到此单个应用的熔断监控已经完成。

技术架构图如下:

技术分享图片

springcloud(五):熔断监控Hystrix Dashboard

标签:请求   tap   clu   ESS   size   说明   架构   ati   ...   

原文地址:http://blog.51cto.com/13777880/2322994

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!