SpringCloud教程之断路器监控(Hystrix + Turbine)(八)

喜欢ヅ旅行 2023-02-12 14:29 147阅读 0赞

SpringCloud断路器监控(Hystrix + Turbine)

在父工程目录下创建一个maven项目,在这个maven项目中添加依赖

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.springframework.cloud</groupId>
  4. <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-web</artifactId>
  9. </dependency>
  10. <dependency>
  11. <groupId>org.springframework.boot</groupId>
  12. <artifactId>spring-boot-starter-actuator</artifactId>
  13. </dependency>
  14. <dependency>
  15. <groupId>org.springframework.cloud</groupId>
  16. <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
  17. </dependency>
  18. <dependency>
  19. <groupId>org.springframework.cloud</groupId>
  20. <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
  21. </dependency>
  22. <dependency>
  23. <groupId>org.springframework.cloud</groupId>
  24. <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
  25. </dependency>
  26. </dependencies>

在配置文件application.yml中添加以下配置

  1. server:
  2. port: 9999
  3. spring:
  4. application:
  5. name: monitor
  6. eureka:
  7. client:
  8. serviceUrl:
  9. defaultZone: http://localhost:7010/eureka/
  10. #http://localhost:9999/hystrix http://localhost:8777/actuator/hystrix.stream
  11. management:
  12. endpoints:
  13. web:
  14. exposure:
  15. include: "*"
  16. cors:
  17. allowed-origins: "*"
  18. allowed-methods: "*"
  19. turbine:
  20. # 需要监控的服务名称
  21. app-config: ribbon-service
  22. aggregator:
  23. clusterConfig: default
  24. clusterNameExpression: new String("default")
  25. combine-host: true
  26. instanceUrlSuffix:
  27. default: actuator/hystrix.stream

启动类

  1. @SpringBootApplication
  2. @EnableEurekaClient
  3. @EnableDiscoveryClient
  4. @RestController
  5. @EnableHystrix
  6. @EnableHystrixDashboard
  7. @EnableCircuitBreaker
  8. @EnableTurbine
  9. public class MonitorApplication {
  10. public static void main(String[] args) {
  11. SpringApplication.run( MonitorApplication.class, args );
  12. }
  13. }

依次启动Eureka、config-server、server02、ribbon-service、feign-service、zuul、还有本服务

在浏览器上访问http://localhost:9999/hystrix

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNzkzMjc1_size_16_color_FFFFFF_t_70

在第一栏填入

  1. http://localhost:8777/actuator/hystrix.stream或http://localhost:9999/turbine.stream

出现以下界面

20200526155530459.png

发表评论

表情:
评论列表 (有 0 条评论,147人围观)

还没有评论,来说两句吧...

相关阅读