-
配置监控
/** * 在被监控的微服务中注册一个serlvet,后期我们就是通过访问这个servlet来获取该服务的Hystrix监控数据的 * 前提:被监控的微服务需要引入springboot的actuator功能 */ @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; }
启动后访问http://localhost:8090/actuator/hystrix.stream确保生效
-
配置仪表盘模块cloud-hystrix-dashboard-9000
1)pom<!--hystrix--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependency> <!--hystrix 仪表盘--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
2)application.yml
server: port: 9000 spring: application: name: cloud-hystrix-dashboard eureka: client: service-url: #eureka server的路径 #注册到集群,多个Eurekaserver地址使用逗号连接起来 defaultZone: http://CloudEurekaServerA:8761/eureka,http://CloudEurekaServerB:8762/eureka instance: #服务实例中显示ip,而不是显示主机名(兼容老的eureka版本) prefer-ip-address: true #例名称: 192.168.1.100:service-provider:8080 instance-id: ${ spring.cloud.client.ip-address}:${ spring.application.name}:${ server.port}:@project.version@
3)启动类 开启 Hystrix board
4) 启动
地址: http://localhost:9000/hystrix
5)登入
在框框中输入监控的地址:http://localhost:8090/actuator/hystrix.stream
点击Monitor Stream
百分⽐:10s内错误请求百分⽐ 实⼼圆: - ⼤⼩:代表请求流量的⼤⼩,流量越⼤球越⼤ - 颜⾊:代表请求处理的健康状态,从绿⾊到红⾊递减,绿⾊代表健康,红⾊就代表很不健康 曲线波动图:记录了2分钟内该⽅法上流量的变化波动图,判断流量上升或者下降的趋势
-
Hystrix Turbine聚合监控 配置仪表盘模块cloud-hystrix-turbine-9001
1) pom<!--hystrix turbine聚合监控--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency> <!--引⼊eureka客户端,微服务架构下的服务都尽量注册到服务中⼼去,便于统⼀管理--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
2) application.yml
server: port: 9001 spring: application: name: cloud-hystrix-turbine eureka: client: service-url: defaultZone: http://CloudEurekaServerA:8761/eureka,http://CloudEurekaServerB:8762/eureka instance: prefer-ip-address: true instance-id: ${ spring.cloud.client.ip-address}:${ spring.application.name}:${ server.port}:@project.version@ #turbine配置 turbine: #appCofing配置需要聚合的服务名称,⽐如这⾥聚合⾃动投递微服务的hystrix监控数据 #聚合多个微服务的监控数据,使⽤英⽂逗号拼 appConfig: service-consumer clusterNameExpression: "'default'" #集群默认名称
3) 启动类 开启 Hystrix Turbine
4) 启动
地址:http://localhost:9001/turbine.stream
5)登入
地址: http://localhost:9000/hystrix
在框框中输入监控的地址:http://localhost:9001/turbine.stream
点击Monitor Stream
笔记9:Spring Cloud Hystrix仪表盘配置
猜你喜欢
转载自blog.csdn.net/Lossdate/article/details/114004669
今日推荐
周排行