服务熔断Hystrix-7 (Hystrix仪表盘监控 搭建一个Hystrix Dashboard服务)

@TOC

	Hystrix仪表盘(Hystrix Dashboard),就像汽车的仪表盘实时显示汽车的各项数据一
样,Hystrix仪表盘主要用来监控Hystrix 的实时运行状态,通过它概们可以看到 Hystrix的各
项指标信息,从而快速发现系统中存在的问题进而解决它。

	要使用Hystrix仪表盘功能,我们首先需要有一个Hystrix Dashboard:这个功能我们可以
在原来的消费者应用上添加,让原来的消费者应用具备Hystrix仪表盘功能,但一般地,微服
务架构思想是推崇服务的拆分,Hystrix Dashboard 也是一个服务,所以通常会单独创建一个
新的工程专门用做 Hystrix Dashboard服务;

搭建一个Hystrix Dashboard服务的步骤

1.创建一个普通的Spring Boot项目

在这里插入图片描述

2.添加Hystrix Dashboard pom依赖

<!-- Hystrix Dashboard 底层实际上用了springboot所以不需要再倒入springboot-starter-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
            <version>1.4.7.RELEASE</version>
        </dependency>

3.在入口类添加注解

@SpringBootApplication

//开启Hystrix 仪表盘功能
@EnableHystrixDashboard
public class Application {

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

}

4.属性配置yml

server:
  port: 8086

5.启动仪表盘 http://localhost:端口(仪表盘):hystrix

在这里插入图片描述
1.仪表盘地址
2.需要监控的服务地址
3.轮询监控延迟时间 默认 2000ms
4.仪表盘标题 默认使用URL

Hystrix监控 (springboot2.0版本后URL:http://localhost:8082/hystrix.stream)

而不是http://localhost:8082/actuator/hystrix.stream

1.消费者项目需要hystrix的依赖

<!--Spring CLoud熔断器起步依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>2.1.1.RELEASE</version>
        </dependency>


2.需要一个spring boot 的服务监控依赖

        <!-- springboot的服务监控依赖 探查springboot健康检查运行状态-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

3.yml配置文件 配置springboot监控断点的访问权限

# 暴露endpoints的,由于endpoints会包含很多敏感信息,除了health和info两个直接支持外,其他默认的都不能访问,所以我们让他都能访问,或者指定
management:
  endpoints:
    web:
      exposure:
      # *表示所有的端点都允许访问
        include: *

# 或者指定成特定的  , 正常都会指定
management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream	

4.访问入口 http://localhost:端口(消费者)/actuator/hystrix.stream(指定端点)

在这里插入图片描述

在这里插入图片描述

5.仪表盘数据

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一只小小狗

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

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

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

打赏作者

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

抵扣说明:

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

余额充值