• Spring Cloud (10) Hystrix-监控面板


    Hystrix DashBoard

      断路器是根据一段时间窗内的请求状况来判断并操作断路器的打开和关闭状态的。Hystrix Dashboard是作为断路器状态的一个组件,提供了数据监控和友好的图形化界面。

    这里使用第一篇创建的david-client项目,在pom.xml中添加相应的依赖:

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

    在启动类中添加@EnableHystrix注解开启断路器,添加@EnableHystrixDashboard注解,开启Hystrix Dashboard

    @EnableHystrix
    @EnableHystrixDashboard
    @EnableEurekaClient
    @SpringBootApplication
    public class ClientApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(ClientApplication.class, args);
        }
    }

    在Controller中 声明断路点HystrixCommand

    @RestController
    public class TestController {
    
        @Value("${server.port}")
        String port;
    
        @GetMapping("/test")
        @HystrixCommand(fallbackMethod = "error")
        public String test() {
            return "test;port:" + port;
        }
    
        public String error(){
            return "error";
        }
    }

    启动eureka-sever,eureka-client

    访问 http://localhost:8762/hystrix 

    这是Hystrix Dashboard监控首页,该页面中并没有具体的监控信息,Dashboard共支持三种不同的监控方式:

      1.默认的集群监控:通过url http://turbine-hostname:port/turbine.stream开启,实现对默认集群的监控。

      2.指定的集群监控:通过url http://turbine-hostname:port/turbine.stream?cluster=[clusterName]开启,实现对clusterName集群的监控。

      3.单体应用的监控:通过url http://hystrix-app:port/hystrix.stream开启,实现对具体某个服务实例的监控。

    前两者都是对集群的监控,需要整合Turbine才能实现。最后一个是单个服务实例的监控。

    delay:此参数用来控制服务器上轮询监控信息的延迟时间,默认为2000毫秒。

    title:该参数为下图Hystrix Stream的内容,不添加显示监控的url。

    在框框中输入:http://localhost:8762/hystrix.stream 、 2000 、 miya  然后点击Monitor Stream按钮

    实心圆:有两种含义,他通过颜色代表了实例的健康程序,健康从绿色、黄色、橙色、红色递减。除了颜色变化也会根据流量发生变化,流量越大,圆越大。

    曲线:用来记录2分钟内流浪的相对变化。

    其他参数:

  • 相关阅读:
    python3 5个带key内置函数
    python3常用内置函数总结
    python入门基础-函数装饰器的理解
    python入门基础-三元表达式、命名空间、作用域、函数名本质、闭包
    python入门基础-初识函数
    第二章001编写脚本
    Appium 自动化测试第一天——基础知识
    python基础-读取文件
    linux6.4 安装python3 pip setuptools
    selenium+python之HTML测试报告
  • 原文地址:https://www.cnblogs.com/baidawei/p/9146103.html
Copyright © 2020-2023  润新知