Spring Cloud学习--容错机制(Hystrix DashBoard之数据监控)

Hystrix监控实践
本文介绍如何使用Actuator和HystrixDashBoard监控Hystrix断路器状态,包括配置依赖、启动类注解及访问监控页面的具体步骤。

本文目录:

一、使用Actuator监控

除了实现容错功能,Hystrix还提供了近乎实时的监控。断路器的状态也会暴露在Actuator提供的/health端点中,只需为项目(该项目可见http://blog.youkuaiyun.com/u012482647/article/details/78148447)添加spring-boot-actuator,重启项目,先访问http://localhost:8777/getString 再访问http://localhost:8777/hystrix.stream ,即可看到实时的监控数据。
因我使用火狐浏览器,每次访问就是下载hystrix.stream文件。这个问题还没解决,望各位大神支支招。

二 、使用Hystrix DashBoard监控

Actuator 能看到的是一大堆数据,而使用Hystrix DashBoard(仪表盘),使得监控数据图形化、可视化。Hystrix仪表板可以显示每个断路器(被@HystrixCommand注解的方法)的状态。步骤如下:

1.创建一个基本的spring boot 工程,添加spring-cloud-starter-hystrix-dashboard依赖。

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

2.启动类上添加@EnableHystrixDashboard 注解


@EnableHystrixDashboard
@SpringBootApplication
public class SpringCloudHystrixDashboardApplication {

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

4.配置文件:

spring.application.name=hystrix-Dashboard
server.port=2001

3.启动项目,访问http://localhost:2001/hystrix 这是Hystrix DashBoard监控首页。

这里写图片描述
在url中输入http://localhost:8777/hystrix.stream ,点击Monitor Stream 出现如图界面,数量指标如图所示:

这里写图片描述

综上,实现了利用Hystrix DashBoard对单个实例的信息监控。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值