前言 Turbine is a tool for aggregating streams of Server-Sent Event (SSE) JSON data into a single stream. The targeted use case is metrics streams from instances in an SOA being aggregated for dashboards.(Github )
通过Turbine实现聚合Hystrix监控数据,连接多台服务器,抓取日志数据,进行聚合,交给仪表盘在同一个监控界面进行展示
部署Turbine服务 添加依赖 pom.xml 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 >
修改配置文件
修改配置文件,连接多台order-service服务器,抓取监控数据,暴露在http://localhost:5001/turbine.stream
app-config:配置聚合的服务idcluster-name-expression:为聚合的监控数据命名,默认名为default
src/main/resources/application.yml 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); } }
完成