2020-12-16 Hystrix(3)

11.5.Dashboard流监控

是什么?

Hystrix Dashboard,它主要用来实时监控Hystrix的各项指标信息。通过Hystrix Dashboard反馈的实时信息,可以帮助我们快速发现系统中存在的问题。

怎么用?
1. 新建一个model命名springcloud-consumer-hystrix-dashboard 导入依赖
<dependencies>
        <!--Hystrix依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <!--Ribbon-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-ribbon</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <!--eureka相关配置-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.buba</groupId>
            <artifactId>springcloud-api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--热部署-->
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
    </dependencies>
2.创建一个application.yml文件添加配置
server:
  port: 9008
3.创建启动类 (在新建的com.buba.springcloud下)
  • 添加开启启监控页面的注解!!!
package com.buba.springcloud;

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

@SpringBootApplication
@EnableHystrixDashboard//开启监控页面
public class DeptConsumerDashboard_9008 {
    public static void main(String[] args) {
        SpringApplication.run(DeptConsumerDashboard_9001.class,args);
    }
}
4.单独启动并测试 访问http://localhost:9008/hystrix

注意:这里可能会报错,我刚开始使用的是9001端口,结构报错说端口被占用,所以我这里直接写成了9008端口!

这是成功页面:
在这里插入图片描述

5.添加一个服务到监控
  • 先启动7001注册中心
  • 在springcloud-provider-dept-hystrix-8001的启动类中添加一个bean
    @Bean
      public ServletRegistrationBean hystrixMetricsStreamServlet(){
          ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
          registrationBean.addUrlMappings("/actuator/hystrix.stream");
          return registrationBean;
      }
    
  • 启动9008监控中心
  • 启动hystrix-8001服务提供者
  • 访问http://localhost:8001/dept/get/1
    在这里插入图片描述
  • 访问http://localhost:8001/actuator/hystrix.stream
    在这里插入图片描述
  • 访问http://localhost:9008/hystrix
    在这里插入图片描述
  • 点击上图中的:
    在这里插入图片描述
    就会出现可视化监控图
    在这里插入图片描述
6.监控面板
  • 如何看
  • 七色
    在这里插入图片描述
  • 一圈
    实心圆:公有两种含义,他通过颜色的变化代表了实例的健康程度
    它的健康程度从绿色<黄色<橙色<红色递减
    该实心圆除了颜色的变化之外,它的大小也会根据实例的请求流量发生变化,流量越大,该实心圆就越大,所以通过该实心圆的展示,就可以在大量的实例中快速发现故障实例和高压力实例
    在这里插入图片描述
  • 一线
    曲线:用来记录2分钟内流量的相对变化,可以通过它来观察到流量的上升和下降趋势!
    在这里插入图片描述
  • 整图说明:
    在这里插入图片描述
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值