Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine.

Turbine

在复杂的分布式系统中,相同服务的节点经常需要部署上百甚至上千个,很多时候,运维人员希望能够把相同服务的节点状态以一个整体集群的形式展现出来,这样可以更好的把握整个系统的状态。 为此,Netflix提供了一个开源项目(Turbine)来提供把多个hystrix.stream的内容聚合为一个数据源供Dashboard展示。

一、构建turbin服务,选择对应模块,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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>lf.liyouyou</groupId>
<artifactId>spring-cloud-netflix-demo</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>lf.liyouyou</groupId>
<artifactId>spring-cloud-turbin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-cloud-turbin</name>
<description>Demo project for Spring Boot</description> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<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-hystrix</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> </project>

二、启动类添加注解

package lf.liyouyou;

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; @SpringBootApplication
@EnableHystrixDashboard
@EnableTurbine
public class SpringCloudTurbinApplication { public static void main(String[] args) {
SpringApplication.run(SpringCloudTurbinApplication.class, args);
} }

二、配置properties

spring.application.name=hystrix-dashboard-turbine
server.port=9092
turbine.appConfig=spring-cloud-netflix-consumer-hystrix,spring-cloud-service
turbine.aggregator.clusterConfig= default
turbine.clusterNameExpression= new String("default")
eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
#默认只开启了health和info,设置为*,则包含所有的web入口端点
management.endpoints.web.exposure.include=*
hystrix.dashboard.proxy-stream-allow-list=*
  • turbine.appConfig :配置Eureka中的serviceId列表,表明监控哪些服务
  • turbine.aggregator.clusterConfig :指定聚合哪些集群,多个使用”,”分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问
  • turbine.clusterNameExpression : 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称;2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default;3. 当clusterNameExpression: metadata[‘cluster’]时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC
  • 新增服务工程
    spring-cloud-service 调用spring-cloud-netflix-provider(复制一份spring-cloud-netflix-eureka-client-application服务即可)服务提供者的服务,
  • 注意新增的
    spring-cloud-service服务调用需要把actuator打开,不然监控该工程的调用
    默认只开启了health和info,设置为*,则包含所有的web入口端点
    management.endpoints.web.exposure.include=*

  启动项目,访问http://localhost:9092/turbine.stream 返回

访问http://localhost:9092/hystrix,进入小熊页面,输入http://localhost:9092/turbine.stream,点击进入turbin聚合监控页

最新文章

  1. VirtualBox Ubuntu Server 16.04 手动设置 网络(IP, DNS, 路由)
  2. Python2.7.12开发环境构建(自动补全)
  3. ie 8 下post提交提交了两次
  4. android之二维码扫描的实现
  5. MySQL物理文件组成
  6. Activity的成员变量
  7. hibernate.properties和hibernate.cfg.xml
  8. 14.4.5 System Tablespace 系统表空间
  9. sublime eslint setup
  10. ASP.NET Web API 2 消息处理管道
  11. java+tomcat开发环境搭建
  12. org.apache.subversion.javahl.ClientException: Previous operation has not finished
  13. Homebrew macOS 包管理
  14. MongoDB的真正性能-实战百万用户
  15. Firbe Channel光纤信道
  16. GS7 使用IPV6的数据库的注册方法
  17. Hibernate5笔记3--详解Hibernate的API
  18. linux cpu、内存、硬盘空间查询
  19. jquery ajax调用WCF,采用System.ServiceModel.WebHttpBinding
  20. springmvc web.xml配置之 -- ContextLoaderListener

热门文章

  1. Dubbo中的统一契约是如何实现的?
  2. Vue基础之Vue的模板语法
  3. 不错的网站压力测试工具webbench
  4. Spring Security OAuth2.0认证授权六:前后端分离下的登录授权
  5. 用git合并分支时,如何保持某些文件不被合并
  6. 编译安装 codeblocks 20.03 mips64el
  7. 在IDEA中用三个jar包链接MongoDB数据库——实现增删改查
  8. XV6学习(9)Lab cow: Copy-on-write fork
  9. 深入理解java虚拟机,GC参考手册
  10. Jenkins (1、自动化发布war包、2、自动化发布nodejs)