SpringCloud全家桶---HystrixDashboard配置与基础功能演示

1、SpringCloud全家桶—注册中心Eureka搭建
2、SpringCloud全家桶—注册中心Eureka高可用环境搭建
3、SpringCloud全家桶—客户端负载均衡Ribbon
4、SpringCloud全家桶—OpenFeign
5、SpringCloud全家桶—断路器Hystrix
6、SpringCloud全家桶—HystrixDashboard配置与基础功能演示
7、SpringCloud全家桶—Zuul网关

HystrixDashboard是为Hystrix监控时提供比较友好的图形化界面,方便用户使用与分析。

要使用HystrixDashboard功能,需要引入三个依赖。

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

然后在Application中将功能开启,并注入ServletRegistrationBean。

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableHystrix
@EnableHystrixDashboard
public class OrderApplication {

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

    @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;
    }
}

启动服务访问http://localhost:18000/hystrix,18000是服务端口号,默认2秒刷新一次,界面如下。
在这里插入图片描述
地址栏输入:localhost:18000/actuator/hystrix.stream,就是在application中配置的url。

registrationBean.addUrlMappings("/actuator/hystrix.stream");

首次访问界面是空白的。
在这里插入图片描述
调用一次服务后就会有信息了,比如访问失败后如下:

在这里插入图片描述
达到一定的请求失败次数后,断路器打开。
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码拉松

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值