学习笔记:微服务-19 Hystrix-Turbine集成监控
Turbine通过eureka可以收集集群的多个Hystrix短路器的状态数据,然后通过Hystrix Dashboard 展示集群的多个短路器状态,达到集中监控微服务运行状态的作用。
上节已经设置好了Hystrix Dashboard服务。
这节介绍turbine的安装使用
1. 新建spring boot项目
pom.xml增加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2. application.properties 配置
server.port: 8503
spring.application.name=MicroserviceHystrixTurbine8503
spring.cloud.discovery.enabled=true
eureka.client.serviceUrl.defaultZone=http://admin:[email protected]:8101/eureka/,http://admin:[email protected]:8102/eureka/
turbine.aggregator.cluster-config=default
turbine.cluster-name-expression=new String("default")
turbine.app-config=MICROSERVICERIBBONHYSTRIX8803,MICROSERVICEFEIGNHYSTRIX8804
# 这个是eureka上显示的微服务名字(含hystrix需要的)
3. 启动类前加注解
@EnableTurbine
4.测试
http://centos7.linbsoft.com:8503/turbine.stream 如果有数据则成功了
5. 在hystrix dashboard上查看
hystrix dashboard页面的监控地址栏填入上面的turbine监控地址即可