SpringCloud2组件之Hystrix Dashboard详解

Hystrix Dashboard:

  Spring Cloud提供的一个仪表盘(Dashboard),用于Hystrix进行监控断路的情况,从而让开发者监控可能出现的问题。

1、创建hystrix-dashboard微服务工程

  我们以通过Hystrix实现调用微服务的超时断路(详见SpringCloud2组件之Hystrix详解),在此基础上,使用Hystrix Dashboard进行断路监控。

(1)client-product组件选择
(2)工程目录
(3)application.yml
server:
  #服务端口
  port: 6001
spring:
  application:
    #服务名称
    name: dashboard
(4)HystrixDashboardApplication
package com.ming.dashboard;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

@SpringBootApplication
@EnableHystrixDashboard  //开启Hystrix Dashboard
public class HystrixDashboardApplication {

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

2、改造client-product微服务工程

(1)pom.xml中添加Actuator依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
(2)application.yml中添加属性
server:
  #服务端口
  port: 8000
spring:
  #服务名称
  application:
      name: product
eureka:
  client:
    service-url:
      #服务注册地址
      defaultZone: http://localhost:9000/eureka/
management:
  endpoints:
    web:
      exposure:
        #actuator监控对外暴露hystrix.stream端点,默认情况下,只会暴露health和info端点
        include: health, info, hystrix.stream

3、测试工程

  依次点击ServerEurekaApplication、ClientProductApplication、ClientUserApplication、HystrixDashboardApplication,工程都启动成功后。在浏览器地址栏访问 http://localhost:6001/hystrix, 其结果如下:

进行配置页面,结果如下:

页面配置完成后,点击Monitor Stream按钮,结果如下:

重新打开一个窗口,多次在浏览器地址栏刷新访问 http://localhost:8000/testHystrixByRibbon, 返回查看监控页面,其结果如下:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值