Spring Cloud 之服务监控 turbine(六)
来源:互联网 发布:吉林快3遗漏 数据 编辑:程序博客网 时间:2024/06/05 21:29
turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群,
因此可以通过turbine来监控集群下hystrix的metrics情况,通过eureka来发现hystrix服务。
新建turbine项目
TurbineApplication.java
package turbine;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.hystrix.EnableHystrix;import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;import org.springframework.cloud.netflix.turbine.EnableTurbine;/** * Created by sai.luo on 2017/4/26. */@SpringBootApplication@EnableTurbine@EnableHystrix@EnableHystrixDashboardpublic class TurbineApplication{ public static void main(String[] args) { SpringApplication.run(TurbineApplication.class,args); }}
pom.xml
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>turbine</artifactId> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <!-- hystrix依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency> <!-- turnbine依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR5</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>
application.yml
spring: application: name: turbineserver: port: 8000turbine: app-config: hello,helloClient ##需要监控的服务名 aggregator: clusterConfig: main ##需要监控的服务集群名 clusterNameExpression: metadata['cluster']eureka: instance: preferIpAddress: true statusPageUrlPath: /info.html client: serviceUrl: defaultZone: http://localhost:8761/eureka/
启动服务
helloserviceeureka 项目 appliation.yml 增加集群配置
更改为
spring: application: name: helloserver: port: 9001eureka: instance: lease-renewal-interval-in-seconds: 3 lease-expiration-duration-in-seconds: 5 metadata-map: cluster: main client: serviceUrl: defaultZone: http://localhost:8761/eureka/ registry-fetch-interval-seconds: 3logging: level: com: netflix: eureka: OFF discovery: OFF
pom.xml增加hystrix依赖包
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId></dependency>
同理ribboneureka 项目 application.yml 增加集群配置
更改后如下
spring: application: name: helloClientserver: port: 20000eureka: instance: lease-renewal-interval-in-seconds: 3 lease-expiration-duration-in-seconds: 5 metadata-map: cluster: main client: serviceUrl: defaultZone: http://localhost:8761/eureka/ registry-fetch-interval-seconds: 3logging: level: com: netflix: eureka: OFF discovery: OFF
pom.xml增加hystrix依赖包
RibbonEurekaApplication.java 增加注解
@EnableHystrix
启动项目
访问 localhost:8000/hystrixx 可以看到页面
注: turbine只能监控hystrix服务,不是hystrix服务,不能监控,如 hello这个服务虽然配置了集群,但是没有使用hystrix,所以不会受监控。
项目地址 https://github.com/luosai001/Spring-Cloud-Sample/tree/master 如果对您有帮助,请点赞,谢谢。
0 0
- Spring Cloud 之服务监控 turbine(六)
- spring cloud之Turbine(九)
- Spring Cloud学习--容错机制(Hystrix之Turbine集群监控)
- Spring Cloud——断路器监控Hystrix Dashboard&Turbine
- Spring Cloud中Hystrix仪表盘与Turbine集群监控
- spring cloud day05【turbine】
- (六)spring cloud云服务架构
- Spring cloud系列十二 监控Hystrix界面:Hystrix dashboard 和 Turbine
- (六)整合spring cloud云服务架构
- Spring Cloud(六)服务网关 zuul 快速入门
- Spring Cloud 之服务网关
- springcloud实战之9断路器-集群监控(turbine)
- spring cloud之zuul路由网关(六)
- Cloud中Hystrix仪表盘与Turbine集群监控
- Spring cloud eureka+Client+Spring boot admin 服务注册监控
- SpringCloud之分布式服务配置中心(Spring Cloud Config)
- Spring Cloud学习--容错机制(Hystrix之服务降级)
- Spring Cloud构建微服务架构(六)高可用服务注册中心
- server2003-ftp
- XListeView和Imageloader的使用
- Mysql 索引创建、删除及查看
- TestNG 入门教程
- MySQL 创建用户并授权、 set命令修改用户密码 、使用mysqladmin命令修改root账户密码
- Spring Cloud 之服务监控 turbine(六)
- ubuntu 14.04 64位 安装Opencv3.1.0 (包含opencv_contrib模块)
- JAVA用for循环输出1!,2!,3!,4!,5!以及它们的和。
- 堆和栈的区别
- Android 7.0 android.os.FileUriExposedException
- 页面作业练习
- SCU4438-Censort
- 程序员应该常问常思考
- 用canvas实现对图片的处理 使用fileAPI