SpringCloud Hystrix集群监控Turbine

 

个人博客网:www.lfuping.cn    (你想要这里多有)

Dashboard仅仅是单机服务监控实际项目基本都是集群,所以这里集群监控用的是turbine。
turbine是基于Dashboard的。

一、创建turbine监控项目:springcloud-hystrix-turbine-1
pom.xml加下依赖;

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>

application.yml:

server:
  port: 9091
  context-path: /
eureka:
  instance:
    hostname: eureka1  #eureka客户端主机实例名称
    appname: hystrix  #客户端服务名
    instance-id: springcloud-hystrix:9091 #客户端实例名称
    prefer-ip-address: true #显示IP
  client: 
    service-url: 
      defaultZone: http://localhost:7001/eureka/
      #集群模式defaultZone: http://lifuping.eureka3.com:6001/eureka/,http://lifuping.eureka2.com:5001/eureka/,http://lifuping.eureka1.com:7001/eureka/ # 集群
      #单机defaultZone: http://localhost:7001/eureka   
      #把服务注册到eureka注册中心
turbine: 
  app-config: PROVIDER   # 指定要监控的应用名称,如果是多个服务用  , 间隔
  clusterNameExpression: "'default'" #表示集群的名字为default
spring: 
  application: 
    name: turbine

二、创建启动类:HystrixTurbineApplication
加注解:@EnableTurbine

package com.li.spingcloud.hystrix.turbine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
import org.springframework.context.annotation.Bean;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
@EnableTurbine
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class })
public class HystrixTurbineApplication {
    public static void main(String[] args) {
        SpringApplication.run(HystrixTurbineApplication.class, args);
    }
}

三、测试:

  1. 先启动eureka单机或者集群(集群记得修改配置);
  2. 在启动服务生产者单机或者集群;
  3. 然后启动服务消费者;
  4. 启动springcloud-hystrix-dashboard-1监控;
  5. 请求http://localhost:8080/consumer/list
    返回正常业务;
  6. 在浏览器直接输入地址http://localhost:9091/turbine.stream 这个路径即可;
    一直是ping,然后data返回数据;

 

  1. 输入http://localhost:9090/hystrix/ 进入仪表盘,输入地址; http://localhost:9091/turbine.stream 看到图形监控界面

 

源码链接: https://pan.baidu.com/s/1_yWYFhxdzvzg53adfiwddQ

提取码: mcyg

 

                                                             

                                                              欢迎关注我的微信公众号:平川大叔

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值