SpringCloud:Hystrix dashboard流监控

基于Hystrix的dashboard流监控

目的:web端可视化监控微服务架构中各服务的访问量,和各服务的健康程度

注意:该服务要启用熔断@EnableCircuitBreaker,并且只能监控有熔断注解@HystrixCommand的方法!

 

流监控首页

 

 

绑定一个服务后的监控

主要监控当前服务的健康程度,及访问量

 

 

 图解

 

 

 

 

 

 

 配置dashboard

一,新建一个dashboard流监控服务
导入相关依赖

        <!--hystrix-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <!--dashboard流监控-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
View Code

 

该服务仅需配置serverport和在主启动类开启流监控注解

server.port:9001

 

 

 

@EnableHystrixDashboard //开启流监控

 

 

 

二,给具有hystrix熔断的服务配置

导入相关依赖

        <!--完善eureka监控信息,属于hystrix-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
View Code

增加一个servlet

@SpringBootApplication
@EnableDiscoveryClient //服务发现,企业级协同开发
@EnableEurekaClient  //开启eureka客户端,在服务启动后自动注册到指定的EurekaServer中
@EnableCircuitBreaker //开启断路器,属于hystrix的包
public class HystrixDeptProvider_8001 {
    public static void main(String[] args) {
        SpringApplication.run(HystrixDeptProvider_8001.class,args);
    }


    //增加一个Servlet
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean bean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        bean.addUrlMappings("/actuator/hystrix.stream");
        return bean;

    }
}

注意:dashboard服务要启用熔断@EnableCircuitBreaker,并且只能监控有熔断注解@HystrixCommand的方法!

 

posted @ 2021-01-29 12:51  凸然猿  阅读(77)  评论(0编辑  收藏  举报