spring cloud hystrix dashboard 集群监控
**************************
集群监控
同步监控:监控信息直接输出到dashboard
异步监控:监控信息发送到消息中间件,消息中间件再将监控信息输出到dashboard
**************************
监控的消费端
@FeignClient(name = "hello-provider",fallback = HelloServiceImpl.class)
public interface HelloService {
@RequestMapping("/hello")
String hello();
@RequestMapping("/hello2")
String hello2(@RequestParam("name")String name);
}
**************************
新建turbine应用
*****************
引入jar包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
</exclusions>
</dependency>
*****************
application.yml
spring:
application:
name: hystrix-turbine
cloud:
consul:
host: 172.18.0.20
port: 8500
turbine:
app-config: feign-consumer
cluster-name-expression: new String("default")
combine-host-port: true
说明:配置文件中指定监控的服务为feign-consumer
*****************
主类加注解:@EnableTurbine
@EnableTurbine
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
****************************
创建hystrix dashboard应用
*****************
引入jar包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
*************************
主类加注解:@EnableHystrixDashBoard
@SpringBootApplication
@EnableHystrixDashboard
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
****************************
集群监控界面