微服务Hystrix Dashboard监控中心搭建

微服务Hystrix Dashboard监控中心搭建
Hystrix Dashboard 是Hystrix熔断器的监控中心,搭建起来非常之方便,直接进入主题。
1.创建一个微服务专门用于监控服务的
引入依赖
		<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
在启动类添加 @EnableHystrixDashboard 标注
@SpringBootApplication
@EnableHystrixDashboard
public class MonitorDashboardApplication {

    public static void main(String[] args) {
        SpringApplication.run(MonitorDashboardApplication.class, args);
    }
}
2.在你要监控熔断的微服务做以下操作
添加依赖
		<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
在配置文件添加配置
#暴露actuator监控的所有端点
management:
  endpoints:
    web:
      exposure:
        include: '*'
3.访问测试
注意如果你的微服务继承了OAuth2.0框架,记得放行springboot下actuator下监控的接口,下面是例子。
 @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .csrf().disable()
                .authorizeRequests()
                .antMatchers("/actuator/**").permitAll()
                .antMatchers("/**").authenticated()
                .and()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
    }

访问 http://localhost:8999/hystrix

在这里插入图片描述

在url填写地方填写 你要监控熔断的微服务的地址 例如http://localhost:8085/actuator/hystrix.stream ,点击Monitor Stream

在这里插入图片描述

4.但是微服务一多,要一个个输地址再去查看,非常麻烦,所以以下做法,可以输入一个url就监控多个微服务的熔断情况
在监控服务的微服务项目引入依赖
		<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
        </dependency>
在启动类标注@EnableTurbine
@SpringBootApplication
@EnableTurbine
@EnableHystrixDashboard
public class MonitorDashboardApplication {

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

}
在配置文件中 ,把监控服务的微服务注册到注册中心中,还有turbine需要检测,那个微服务,要配置微服务名
server:
  port: 8999

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8083/eureka/

spring:
  application:
    name: monitor-dashboard

turbine:
  # 要监控的多个微服务列表 用英文逗号隔开
  app-config: employeetwo
  cluster-name-expression: "'default'"
完成测试,访问http://localhost:8999/hystrix监控微服务
在url填写框,填写http://localhost:8085/turbine.stream,点击Monitor Stream

在这里插入图片描述

在这里插入图片描述

这时候,你就可以看到,你在配置文件中配置的微服务的熔断信息类





一键查询淘宝/拼多多内部优惠券,每日大额外卖红包,购物省钱的宝藏工具
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值