Spring Cloud入门教程-使用Hystrix Dashboard 监控熔断器的状态

修改eureka-client-ribbon 项目,添加依赖:

org.springframework.boot

spring-boot-starter-actuator

org.springframework.cloud

spring-cloud-starter-netflix-hystrix-dashboard

在启动类EurekaCli

【一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义】

开源完整内容戳这里

entRibbonApplication上添加注解@EnableHystrixDashboard。

@EnableHystrixDashboard

@EnableHystrix

@EnableEurekaClient

@SpringBootApplication

@ComponentScan(“com.springcloud.demo.eurekaclientribbon”)

public class EurekaClientRibbonApplication {

public static void main(String[] args) {

SpringApplication.run(EurekaClientRibbonApplication.class, args);

}

}

还需要添加ServletRegistrationBean ,这是新版本做的修改,这里在RibbonConfig中添加。

@Bean

public ServletRegistrationBean getServlet() {

HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();

ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);

registrationBean.setLoadOnStartup(1);

registrationBean.addUrlMappings("/actuator/hystrix.stream");

registrationBean.setName(“HystrixMetricsStreamServlet”);

return registrationBean;

}

启动eureka-server,eureka-client,eureka-client-riibon,浏览器请求http://localhost:8795/hystrix

在界面上分别输入http://localhost:8795/actuator/hystrix.stream,2000,ribbon,点击Monitor Stream,界面出现两个loading。。。请求http://localhost:8795/main调用eureka-client中的服务。

界面如上图。多次点击后灰色的小圆圈会变大,直线会上扬,具体效果自己验证。

在feign中的配置与ribbon 相同,这里不再赘述。

使用Turbine 中聚合监控

===============

在使用 Hystrix Dashboard组件监控服务的熔断器状况时,每个服务都有Dashboard主页,当服务数量很多时,监控非常不方便。为了同时监控多个服务的熔断器的状Turbine用于聚合多个 Hystrix Dashboard, Netflix开源了 Hystrix的另一个组件 Turbine

将多个 Hystrix Dashboard组件的数据放在一个页面上展示,进行集中监控。

创建新的Module eureka-monitor-client


pom.xml如下:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns=“http://maven.apache.org/POM/4.0.0” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>

4.0.0

com.springcloud.demo

springcloud-demo

1.0-SNAPSHOT

eureka-monitor-client

0.0.1-SNAPSHOT

jar

eureka-monitor-client

Demo project for Spring Boot

org.springframework.boot

spring-boot-starter-actuator

org.springframework.cloud

spring-cloud-starter-netflix-turbine

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-maven-plugin

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值