Hystrix监控面板与监控数据聚合

LD is tigger forever,CG are not brothers forever, throw the pot and shine.
Modesty is not false, solid is not naive, treacherous but not deceitful, stay with good people, and stay away from poor people.
talk is cheap, show others the code,Keep progress,make a better result.

目录

概述

断路器是根据一段时间窗内的请求情况来判断并操作断路器的打开和关闭状态的。而这些请求情况的指标信息都是HystrixCommand和HystrixObservableCommand实例在执行过程中记录的重要度量信息,它们除了Hystrix断路器实现中使用之外,对于系统运维和排查问题也有非常大的帮助。这些指标信息会以“滚动时间窗”与“桶”结合的方式进行汇总,并在内存中驻留一段时间,以供内部或外部进行查询使用,Hystrix Dashboard就是这些指标内容的消费者之一!

架构特性

设计思路

实现思路分析

一: 创建一个springBoot-hystrix-dashboard应用(并引入依赖)

<modelVersion>4.0.0</modelVersion>
    <artifactId>springBoot-hystrix-dashboard</artifactId>
<dependencies>
    <!--使用到的版本是1.3.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>
    <!--使用到的版本是1.5.3-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

二: 在启动主类加上@EnableHystrixDashboard,启用Hystrix Dashboard功能。

@EnableHystrixDashboard //启用Hystrix仪表板
@SpringBootApplication
public class HystrixDashboardApplication {

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

到此就配置完成了, 启动项目访问http://localhost:自己应用端口(11000)/hystrix, 看到下面页面就说明搭建成功

: 在需要监控的模块中加入依赖:
Hystrix Dashboard监控单实例节点需要通过访问实例的/hystrix.stream接口来实现,自然我们需要为服务实例添加这个端点,而添加该功能的步骤也同样简单,只需要下面两步

四: 在启动应用类中加上@EnableCircuitBreaker或@EnableHystrix注解,开启了断路器功能
无论你使用的是feign自带的熔断器,都需要导入依赖与注解开启熔断器功能!

我们可以在Hystrix Dashboard的首页输入http://localhost:被监控应用端口(13000)/hystrix.stream,已启动对springBoot-client的监控,点击Monitor Stream按钮,此时我们可以看到如下页面:

Hystrix监控数据聚合

Turbine简介
监控首页提到的通过Turbine的群集的监控端点/turbine.stream,它是用来监控集群的。从端点的命名来看,它需要引入Turbine,通过它来汇集监控信息,并将聚合后的信息提供给Hystrix Dashboard来集中展示和监控在这里插入代码片

<artifactId>dashboard-turbine</artifactId>
     <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-turbine</artifactId>
            <version>1.3.1.RELEASE</version>
        </dependency>
        <!-- 版本是2.1.4-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

2.创建应用启动类TurbineApplication,并使用@EnableTurbine注解开启Turbine

@SpringBootApplication
@EnableTurbine //启用Turbine
public class DashboardTurbineApplication {
    public static void main(String[] args) {
        SpringApplication.run(DashboardTurbineApplication.class,args);
    }
}

三: 在application.yml配置文件加入urbine配置

#服务名为turbine
spring:
  application:
    name: turbine

server:
  port: 15000

#管理服务器端口
management:
  server:
    port: 15000

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka
  instance:
    prefer-ip-address: true

  #参数指定了需要收集监控信息的服务名; 多个以',' 隔开
turbine:
  app-config: eureka-client-two,eureka-client
  #指定集群的名称为default,当服务实例非常多的时候,可以启动多个Turbine来
  #构建不同的聚合集群,而该参数可以区分这些不同的集群,同时该参数可以在
  #Hystrix仪表盘中用来定位不同的聚合集群,只需在Hystrix Stream的URL中通过cluster
  #参数来指定。
  cluster-name-expression: new String('default')
  #当该参数未true(默认就是true),可以让同一主机上的服务通过主机名与端口号
  #的组合来进行区分,默认情况下会以host来区分不同的服务,这
  #会使得在本地调试的时候,本机上不同服务聚合成一个服务来统计
  combine-host-port: true


相关工具如下:

实验效果:(解决思路)

分析:

小结:

主要讲述了一些Hystrix监控面板与监控数据聚合,里面有许多不足,请大家指正~

参考资料和推荐阅读

1.链接: 参考资料.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

执于代码

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

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

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

打赏作者

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

抵扣说明:

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

余额充值