Turbine (provided by the Spring Cloud Netflix project), aggregates multiple instances Hystrix metrics streams, so the dashboard can display an aggregate view. Turbine uses the DiscoveryClient interface to lookup relevant instances.
Hystrix是Netflix解决自己业务不稳定性的一个限流容错框架,可以帮助我们解决微服务架构体系中的限流、降级、熔断等功能。提高系统稳定性,提供了完善的监控实现,并且Hystrix可以根据监控数据动态调整内部处理机制。
Hystrix Dashboard提供了数字与图形化的调用监控情况。结合Turbine可实现多Hystrix实例监控整合。
https://github.com/andyChenHuaYing/spring-cloud-demo
与 二:Spring Cloud 之Eureka服务发布与注册没有任何区别。
与十三:Spring Cloud 之Hystrix Dashboard#2.4没有任何区别
<?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">
<parent>
<artifactId>spring-cloud-finchley-demo</artifactId>
<groupId>org.oscar.scd</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eureka-hystrix-dashboard-another</artifactId>
<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-eureka-client</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix-dashboard -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
</dependencies>
</project>
server:
port: 8786
spring:
application:
name: eureka-hystrix-dashboard-another
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
management:
endpoints:
web:
exposure:
include: '*'
package org.oscar.scd.eureka.hystrix.dashboard.another;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@EnableHystrix
@RestController
@EnableEurekaClient
@EnableCircuitBreaker
@EnableDiscoveryClient
@SpringBootApplication
@EnableHystrixDashboard
public class EurekaHystrixDashboardAnotherApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaHystrixDashboardAnotherApplication.class, args);
}
@Value("${spring.application.name}")
private String appName;
@RequestMapping("/appName")
@HystrixCommand(fallbackMethod = "errorMsg")
public String getAppName() {
return this.appName;
}
@SuppressWarnings("unused")
public String errorMsg() {
return "Error msg by hystrix.";
}
}
<?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">
<parent>
<artifactId>spring-cloud-finchley-demo</artifactId>
<groupId>org.oscar.scd</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eureka-hystrix-dashboard-turbine</artifactId>
<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-eureka-client</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix-dashboard -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
</dependencies>
</project>
server:
port: 8787
spring:
application:
name: eureka-hystrix-dashboard-turbine
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
cors:
allowed-origins: "*"
allowed-methods: "*"
turbine:
app-config: eureka-hystrix-dashboard-another,eureka-hystrix-dashboard
aggregator:
clusterConfig: default
clusterNameExpression: new String("default")
combine-host: true
instanceUrlSuffix:
default: actuator/hystrix.stream
package org.oscar.scd.eureka.hystrix.dashboard.turbine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
import org.springframework.web.bind.annotation.RestController;
@EnableHystrix
@EnableTurbine
@RestController
@EnableEurekaClient
@EnableCircuitBreaker
@EnableDiscoveryClient
@SpringBootApplication
@EnableHystrixDashboard
public class EurekaHystrixDashboardTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaHystrixDashboardTurbineApplication.class, args);
}
}
最简单的方式添加一个SpringBoot启动类型的启动类就行,如果对SpringBoot有所了解或者看过前面系列的文章,这里很简单。
略
略
略
略
EurekaServerSingletonApplication
EurekaHystrixDashboardApplication
EurekaHystrixDashboardAnotherApplication
EurekaHystrixDashboardTurbineApplication
访问:http://localhost:8785/hystrix
访问:http://localhost:8785/appName调用服务
eureka-hystrix-dashboard
eureka-hystrix-dashboard-another
http://localhost:8787/turbine.stream
、2000
。注意是8787端口的turbine.stream,如果没有数据,多调用几次服务端口九:对微服务限流容错的理解
十一:对微服务调用链监控的理解
十:对微服务监控系统分层和监控架构的理解
https://github.com/Netflix/hystrix
http://cloud.spring.io/spring-cloud-static/Finchley.SR1/multi/multi_spring-cloud-consul-turbine.html