Hystrix: Dashboard流监控

接上两张服务熔断 

Hystrix: Dashboard流监控_第1张图片

 Hystrix: Dashboard流监控_第2张图片

Hystrix: Dashboard流监控_第3张图片

 Hystrix: Dashboard流监控_第4张图片

 开始搭建Dashboard流监控

pom依赖



    
        springcloud
        com.kuang
        1.0-SNAPSHOT
    
    4.0.0

    springcloud-consumer-hystrix-dashboard

    
        8
        8
    

    
    
        
        
            org.springframework.cloud
            spring-cloud-starter-hystrix
            1.4.6.RELEASE
        

        
        
            org.springframework.cloud
            spring-cloud-starter-hystrix-dashboard
            1.4.6.RELEASE
        


        
        
            org.springframework.cloud
            spring-cloud-starter-ribbon
            1.4.6.RELEASE
        

        
        
            org.springframework.cloud
            spring-cloud-starter-eureka
            1.4.6.RELEASE
        

        
            com.kuang
            springcloud-api
            1.0-SNAPSHOT
        
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
        
            org.springframework.boot
            spring-boot-devtools
        

    



    org.springframework.cloud
    spring-cloud-starter-hystrix
    1.4.6.RELEASE




    org.springframework.cloud
    spring-cloud-starter-hystrix-dashboard
    1.4.6.RELEASE

主启动类

package com.kuang.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

@SpringBootApplication
@EnableHystrixDashboard//开启
public class DeptConsumerDashboard_9001 {
    public static void main(String[] args) {
        SpringApplication.run(DeptConsumerDashboard_9001.class,args);
    }
}

启动 

访问http://localhost:9001/hystrix

Hystrix: Dashboard流监控_第5张图片

 启动集群7001

Hystrix: Dashboard流监控_第6张图片

 在8001提供者里加个依赖



    org.springframework.cloud
    spring-cloud-starter-hystrix
    1.4.6.RELEASE

在熔断里用这个监控才有效

主启动类里加一个bean放入IOC容器里

package com.kuang.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient //在服务启动后自动注册到 eureka服务端
@EnableDiscoveryClient//服务发现~
@EnableCircuitBreaker//添加对熔断的支持  ,开启断路器
public class DeptApplicationProviderHystrix_8001 {
    public static void main(String[] args) {
        SpringApplication.run(DeptApplicationProviderHystrix_8001.class,args);
    }


    //增加一个Servlet,配合我们的监控使用
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");//添加映射路径
        return registrationBean;
    }

}

Hystrix: Dashboard流监控_第7张图片

 Hystrix: Dashboard流监控_第8张图片

 Hystrix: Dashboard流监控_第9张图片

Hystrix: Dashboard流监控_第10张图片

 Hystrix: Dashboard流监控_第11张图片

 Hystrix: Dashboard流监控_第12张图片

 服务熔断机制Hystrix: Dashboard流监控_第13张图片

 

你可能感兴趣的:(SpringCloud,hystrix)