zoukankan      html  css  js  c++  java
  • 6、Dashboard流监控

    1、新建监控模块:springcloud-consumer-hystrix-dashboard

    pom依赖:

    <dependencies>
            <!--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>
            <!--Ribbon-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-ribbon</artifactId>
                <version>1.4.6.RELEASE</version>
            </dependency>
            <!--Eureka-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka</artifactId>
                <version>1.4.6.RELEASE</version>
            </dependency>
            <!--我们需要拿到实体类,所以要配置api moudle-->
            <dependency>
                <groupId>com.zhixi</groupId>
                <artifactId>springcloud-01-api</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <!--热部署-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
        </dependencies>

    2、编写端口配置

    server:
      port: 9001
    

    3、启用Hystrix仪表板(主配置类)

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

    开启9001服务可以看到监控页面:

    4、往服务里面放入监控实例

    在springcloud-provider-dept-8001-hystrix模块的主启动类中添加servlet

    @EnableCircuitBreaker
    // 启用发现客户端
    @EnableDiscoveryClient
    // 开启Eureka客户端注解,在服务启动后自动向注册中心注册服务
    @EnableEurekaClient
    // 启动类
    @SpringBootApplication
    public class DeptProvider_hystrix_8001 {
        public static void main(String[] args) {
            SpringApplication.run(DeptProvider_hystrix_8001.class, args);
        }
    //增加一个 Servlet @Bean public ServletRegistrationBean hystrixMetricsStreamServlet(){ ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet()); //访问该页面就是监控页面 registrationBean.addUrlMappings("/actuator/hystrix.stream"); return registrationBean; } }

    5、测试监控

    开启7001服务注册

    开启9001服务监控

    开启hystrix8001服务创建

    访问请求,查看监控信息:

    进入监控页面:localhost:9001/hystrix

    查看监控页面:

  • 相关阅读:
    C语言打印记事本内搜索字符串所在行信息
    原创:C语言打开、下载、删除网页,统计网页字符个数
    JAVA GUI编程学习笔记目录
    13.JAVA之GUI编程将程序打包jar
    12.JAVA之GUI编程打开与保存文件
    11.JAVA之GUI编程菜单
    10.JAVA之GUI编程弹出对话框Dialog
    php中的一些不常见的问题foreach/in_array[开发篇]
    微软职位内部推荐-Senior SDE
    微软职位内部推荐-SDE II
  • 原文地址:https://www.cnblogs.com/zhangzhixi/p/14386606.html
Copyright © 2011-2022 走看看