前言
聚合Hystrix监控数据,连接多台服务器,抓取日志数据,进行聚合,交给仪表盘在同一个监控界面进行展示
搭建Turbine服务
添加Turbine依赖
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies>
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
|
配置
- 编辑
application.yml
配置文件,连接多台order-service
服务器,抓取监控数据,暴露在http://localhost:5001/turbine.stream
app-config
:配置聚合的服务id
cluster-name-expression
:为聚合的监控数据命名,默认名为default
1 2 3 4 5 6 7 8 9 10 11 12
| spring: application: name: turbine server: port: 5001 eureka: client: service-url: default: http://eureka1:2001/eureka,http://eureka2:2002/eureka turbine: app-config: order-server cluster-name-expression: new String("default")
|
启动类
- 添加
@EnableTurbine
注解启动Turbine
1 2 3 4 5 6 7
| @EnableTurbine @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
|
完成