zoukankan      html  css  js  c++  java
  • springboot hystrix turbine 聚合监控

    1.新建Module  eureka-monitor-client

    2.父级pom中添加module

    3.编写eureka-monitor-client 中的pom

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.hc</groupId>
            <artifactId>demoparent</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <artifactId>eureka-monitor-client</artifactId>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <!-- 引入关于 eureka-server的依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
                <version>2.0.2.RELEASE</version>
            </dependency>
            <!-- 引入关于 hystrix的依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
                <version>2.0.2.RELEASE</version>
            </dependency>
    
            <!-- 引入关于 hystrix Dashboard的依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
                <version>2.0.2.RELEASE</version>
            </dependency>
            <!-- 引入关于 turbine 的依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
                <version>2.0.2.RELEASE</version>
            </dependency>
            <!--运行状态监控-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <!--mybatis配置 start-->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>1.2.0</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.39</version>
            </dependency>
            <!--mybatis配置 end-->
        </dependencies>
    </project>

    4.编写application.yml

    server:
      port: 8766
    spring:
      main:
        allow-bean-definition-overriding: true
      datasource:
        url: jdbc:mysql://192.168.9.1:3306/test1?useUnicode=true&characterEncoding=utf8
        username: root
        password: 123456
        driver-class-name: com.mysql.jdbc.Driver
      application:
        name: eureka-montior-client
    eureka:
      client:
        #改变eureka server的检查方式,使用actuator 的health进行检查,可能会检查到数据库
        healthcheck:
          enabled: true
        service-url:
          defaultZone: http://localhost:8761/eureka/
      instance:
        prefer-ip-address: true
        instanceId: ${spring.application.name}:${server.port}
        # 每隔10s发送一次心跳
        lease-renewal-interval-in-seconds: 10
        # 告知服务端30秒还未收到心跳的话,就将该服务移除列表
        lease-expiration-duration-in-seconds: 30
        #改变eureka 服务端的 status 状态跳转查看页面
        status-page-url-path: /actuator/health
    management:
      endpoints:
        web:
          exposure:
            include: "*"
      server:
        port: 10115
        servlet:
          context-path: /
        ssl:
          enabled: false
      endpoint:
        health:
          show-details: always
        hystrix:
          stream:
            enabled: true
    turbine:
      aggregator:
        cluster-config: default
      app-config: eureka-ribbon-client,eureka-feign-client
      cluster-name-expression: new String("default")

    5.主函数

    package com.example.eurekamonitorclient;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.hystrix.EnableHystrix;
    import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
    import org.springframework.cloud.netflix.turbine.EnableTurbine;
    
    @SpringBootApplication
    @EnableTurbine
    @EnableHystrix
    @EnableHystrixDashboard
    public class EurekaMonitorClientApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(EurekaMonitorClientApplication.class, args);
        }
    
    }

    6.输入 http://192.168.9.6:8766/turbine.stream 显示

    7.输入http://192.168.9.6:8766/hystrix 显示

     8.输入value值 http://192.168.9.6:8766/turbine.stream 点击  Monitor Stream 显示

    欢迎指正:haizi2014@qq.com
  • 相关阅读:
    (转)Android 序列化对象接口Parcelable使用方法
    (转)在android中画圆形图片的几种办法
    (转)有趣的动画视图集合:Android View Animations
    (转)如何将一个Android工程作为另一个Android工程的库来使用
    (转)解析BroadcastReceiver之你需要了解的一些东东
    (转)Android系列之Fragment(一)----Fragment加载到Activity当中
    (转)推荐安卓开发神器(里面有各种UI特效和实例)
    (转)android仿win8 metro磁贴布局,可以随便的拖动以改变布局的位置
    (转)Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性以及自定义链接到下一个Activity
    Android 官方文档 Training部分翻译
  • 原文地址:https://www.cnblogs.com/hcfan/p/10155429.html
Copyright © 2011-2022 走看看