zoukankan      html  css  js  c++  java
  • springdashboard环境搭建

    SpringCloud Hystrix Dashboard

    Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。

    监控服务pom配置文件

           <!--系统注册与监控服务-->
           <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>
            <!--hystrix仪表盘-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
            </dependency>
    

      application.properties

    server.port=8070
    spring.application.name=claimdashboard
    
    eureka.client.service-url.defaultZone=http://localhost:8091/eureka/
    eureka.client.registerWithEureka=true
    eureka.client.fetchRegistry=true
    @SpringBootApplication
    @EnableHystrixDashboard
    public class ClaimdashboardApplication {
        /*
        启动输入http://localhost:8070/hystrix
        再输入某个需要监控的服务 http://localhost:8030/hystrix.stream
         */
    
        public static void main(String[] args) {
            SpringApplication.run(ClaimdashboardApplication.class, args);
        }
    }

    被监控服务的配置

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
    #服务名称
    spring.application.name=claimaudit
    #配置服务中心注册地址
    eureka.client.service-url.defaultZone=http://localhost:8091/eureka/
    eureka.client.instance.lease-renewal-interval-in-seconds=30
    feign.hystrix.enabled=true
    @SpringBootApplication
    @EnableDiscoveryClient  //注册服务
    @EnableFeignClients     //开启feign
    @EnableHystrix //开启断路器
    @EnableCircuitBreaker
    public class ClaimauditApplication {
        public static void main(String[] args) {
            SpringApplication.run(ClaimauditApplication.class, args);
    
        }
    }

    主要是下面这段代码,如果不添加监控服务会报连接不上的错误

    @Configuration
    public class HystrixConfig {
    
        @Bean
        public HystrixMetricsStreamServlet hystrixMetricsStreamServlet(){
            return new HystrixMetricsStreamServlet();
        }
    
        @Bean
        public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet){
            ServletRegistrationBean registrationBean = new ServletRegistrationBean();
            registrationBean.setServlet(servlet);
            //是否启用该registrationBean
            registrationBean.setEnabled(true);
            registrationBean.addUrlMappings("/hystrix.stream");
            return registrationBean;
        }
    }
  • 相关阅读:
    VC多文档编程技巧(取消一开始时打开的空白文档)
    GetActiveView 返回 NULL 为 MDI 框架窗口
    UC何小鹏:移动互联网创业需警惕五大“不靠谱
    vc:如何从Internet上有效而稳定地下载文件
    python操作文件
    python if条件判断
    python使用退格键时出现^H解决方法
    Python中列表,元组,字典,集合的区别
    python调用shell脚本
    python调用shell命令
  • 原文地址:https://www.cnblogs.com/mutong1228/p/10149736.html
Copyright © 2011-2022 走看看