关于java:分布式微服务监控系统Jellyfish使用介绍

4次阅读

共计 9847 个字符,预计需要花费 25 分钟才能阅读完成。

Jellyfish 是一款轻量级的, 用 Java 写的, 散布式微服务实时监控零碎,可无缝对接 Spring Boot 或 Spring Cloud 工程

Jellyfish 提供的监控性能次要分为两个局部:

  1. 应用程序日志对立收集和查问
  2. 统计和监控 SpringBoot 应用程序 HTTP 接口 3 个指标:申请耗时,错误率,并发度

Jellyfish 部署形式
Jellyfish 分为服务端和 agent 端
服务端 通常是一个独立的 SpringBoot 利用或集群,集群模式是通过另一个微服务分布式合作框架 tridenter 实现的,Jellyfish 服务端还须要部署 Redis 和 ElasticSearch
Agent 端 通常是退出了 jellyfish 相干 jar 包的另一组 SpringBoot 利用或集群,它们向服务端实时发送数据包。

Jellyfish 的个性:

  1. Jellyfish 服务端基于流式计算框架 vortex(底层是 Netty4),低提早,高并发,且反对 TCP 和 HTTP 两种传输协定
  2. Jellyfish 服务端的网络通信层依赖 vortex 框架,反对动静程度扩大,反对数据最终一致性
  3. Jellyfish 的利用接口统计是准实时的,纯内存计算,默认的统计工夫窗口为 1 分钟(可自定义),但统计的接口数量变多可能会影响实时性,经测试,最大提早放弃在 1 分钟内,均匀提早在秒级。

Jellyfish 系列一共有 4 个子工程:

  1. jellyfish-console 
    Jellyfish Web 控制台,可独立运行,通常作为服务端,当然你也能够自定义服务 端,通过应用注解 @EnableJellyfishServer
  2. jellyfish-http-spring-boot-starter 
    jar 包,Jellyfish 监控利用程序接口进行指标统计的 Agent 程序包
  3. jellyfish-slf4j   
    jar 包,Jellyfish 对接 slf4j(目前只实现了 logback 对接),对立利用收集日志的
    agent 程序包
    4. jellyfish-spring-boot-starter  Jellyfish 外围 jar 包, 实现了全副的外围性能

Install

<dependency>
      <artifactId>jellyfish-spring-boot-starter</artifactId>
     <groupId>com.github.paganini2008.atlantis</groupId>
     <version>1.0-RC1</version>
</dependency>

Jellyfish-console 应用阐明

如何对接 slf4j, 对立收集日志:

你的应用程序须要:

  1. pom.xml 增加依赖

    <dependency>
       <artifactId>jellyfish-slf4j</artifactId>
      <groupId>com.github.paganini2008.atlantis</groupId>
      <version>1.0-RC1</version>
    </dependency>
  2. 批改 logback.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <appender name="logTracker" class="indi.atlantis.framework.jellyfish.slf4j.logback.HttpTransportClientAppender">
    <applicationName>tester5</applicationName> <!-- 批改成你的 applicationName -->
    <brokerUrl>http://192.168.159.1:10010</brokerUrl> <!-- 批改 Jellyfish console 地址 -->
    </appender>
    <!-- omit other configuration -->
    <root level="info">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="INFO" />
    <appender-ref ref="ERROR" />
    <appender-ref ref="logTracker" />  <!-- 援用你定义的 appender -->
    </root>
    </configuration>

    目前只反对 logback, 将来会反对更多

  3. 先启动 Jellyfish-console
    启动命令:java -jar jellyfish-console-1.0-RC1.jar
    默认端口:6100 地址:http://localhost:6100/jellyfish/log/
  4. 再启动你的应用程序,此时日志会源源不断的流入 Jellyfish Console:

    阐明:
    jellyfish 服务端从 agent 端承受来的每行日志数据会保留在 es 里。

如何对接 Spring Boot 或 Spring Cloud 我的项目,统计 HTTP 接口指标?
你的利用须要:

  1. 批改你的 pom.xml, 增加:

    <dependency>
    <artifactId>jellyfish-http-spring-boot-starter</artifactId>
    <groupId>com.github.paganini2008.atlantis</groupId>
    <version>1.0-RC1</version>
    </dependency>
  2. 在 application.properties 退出:

    atlantis.framework.jellyfish.brokerUrl=http://localhost:6100  # Jellyfish console 地址
  3. 应用压测工具测试某一个接口,如图:
    接口列表:

    点击 View

    上图显示的是并发度,QPS, 均匀响应工夫

    上图显示的是响应工夫面积图

    上图显示的是接口调用次数面积图

按 F12,查看返回的 json 数据:

{
    "msg": "ok",
    "data": {
        "20:05:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623585900737
            }
        },
        "20:06:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623585960737
            }
        },
        "20:07:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586020737
            }
        },
        "20:08:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586080737
            }
        },
        "20:09:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586140737
            }
        },
        "20:10:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586200737
            }
        },
        "20:11:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586260737
            }
        },
        "20:12:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586320737
            }
        },
        "20:13:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586380737
            }
        },
        "20:14:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586440737
            }
        },
        "20:15:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586500737
            }
        },
        "20:16:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586560737
            }
        },
        "20:17:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586620737
            }
        },
        "20:18:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586680737
            }
        },
        "20:19:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586740737
            }
        },
        "20:20:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586800737
            }
        },
        "20:21:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586860737
            }
        },
        "20:22:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586920737
            }
        },
        "20:23:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623586980737
            }
        },
        "20:24:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587040737
            }
        },
        "20:25:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587100737
            }
        },
        "20:26:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587160737
            }
        },
        "20:27:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587220737
            }
        },
        "20:28:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587280737
            }
        },
        "20:29:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587340737
            }
        },
        "20:30:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587400737
            }
        },
        "20:31:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587460737
            }
        },
        "20:32:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587520737
            }
        },
        "20:33:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587580737
            }
        },
        "20:34:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587640737
            }
        },
        "20:35:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587700737
            }
        },
        "20:36:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587760737
            }
        },
        "20:37:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587820737
            }
        },
        "20:38:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587880737
            }
        },
        "20:39:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623587940737
            }
        },
        "20:40:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588000737
            }
        },
        "20:41:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588060737
            }
        },
        "20:42:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588120737
            }
        },
        "20:43:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588180737
            }
        },
        "20:44:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588240737
            }
        },
        "20:45:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588300737
            }
        },
        "20:46:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588360737
            }
        },
        "20:47:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588420737
            }
        },
        "20:48:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588480737
            }
        },
        "20:49:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588540737
            }
        },
        "20:50:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588600737
            }
        },
        "20:51:00": {
            "rt": {
                "middleValue": 0,
                "count": 0,
                "highestValue": 0,
                "lowestValue": 0,
                "timestamp": 1623588660737
            }
        },
        "20:52:00": {
            "rt": {
                "middleValue": 2158,
                "count": 68,
                "highestValue": 4941,
                "lowestValue": 1,
                "timestamp": 1623588778333
            }
        },
        "20:53:00": {
            "rt": {
                "middleValue": 2252,
                "count": 1815,
                "highestValue": 4996,
                "lowestValue": 0,
                "timestamp": 1623588839757
            }
        },
        "20:54:00": {
            "rt": {
                "middleValue": 2233,
                "count": 2680,
                "highestValue": 5000,
                "lowestValue": 0,
                "timestamp": 1623588899641
            }
        },
        "20:55:00": {
            "rt": {
                "middleValue": 2306,
                "count": 2605,
                "highestValue": 4994,
                "lowestValue": 0,
                "timestamp": 1623588959700
            }
        },
        "20:56:00": {
            "rt": {
                "middleValue": 2224,
                "count": 2669,
                "highestValue": 5422,
                "lowestValue": 0,
                "timestamp": 1623589019949
            }
        },
        "20:57:00": {
            "rt": {
                "middleValue": 2239,
                "count": 2678,
                "highestValue": 4997,
                "lowestValue": 0,
                "timestamp": 1623589079640
            }
        },
        "20:58:00": {
            "rt": {
                "middleValue": 2233,
                "count": 2678,
                "highestValue": 4998,
                "lowestValue": 0,
                "timestamp": 1623589139980
            }
        },
        "20:59:00": {
            "rt": {
                "middleValue": 2305,
                "count": 2601,
                "highestValue": 4998,
                "lowestValue": 0,
                "timestamp": 1623589199745
            }
        },
        "21:00:00": {
            "rt": {
                "middleValue": 2227,
                "count": 2678,
                "highestValue": 5000,
                "lowestValue": 0,
                "timestamp": 1623589259579
            }
        },
        "21:01:00": {
            "rt": {
                "middleValue": 2243,
                "count": 2677,
                "highestValue": 4998,
                "lowestValue": 0,
                "timestamp": 1623589319569
            }
        },
        "21:02:00": {
            "rt": {
                "middleValue": 2255,
                "count": 2656,
                "highestValue": 5000,
                "lowestValue": 0,
                "timestamp": 1623589378556
            }
        },
        "21:03:00": {
            "rt": {
                "middleValue": 2288,
                "count": 2616,
                "highestValue": 5000,
                "lowestValue": 0,
                "timestamp": 1623589439666
            }
        },
        "21:04:00": {
            "rt": {
                "middleValue": 1272,
                "count": 152,
                "highestValue": 4271,
                "lowestValue": 0,
                "timestamp": 1623589441456
            }
        }
    },
    "success": true,
    "statusCode": 200
}

Jellyfish 接口统计局部调用了 vortex 的 metric 模块的 sdk,,所以是基于工夫序列的,默认统计工夫窗口是 1 分钟,滚动保留前 60 条数据,历史数据默认不落地,但能够通过实现 MetricEvictionHandler 和 MetricSequencerFactory 接口进行扩大,参考 vortex metrics

最初,Jellyfish 服务端的参考配置:

server.port=6100

spring.application.name=jellyfish-console
spring.application.cluster.name=jellyfish-console-cluster

#management.endpoints.web.exposure.include=*
#management.endpoint.health.show-details=always
#management.security.enabled=false
#spring.boot.admin.client.url=http://localhost:10081

atlantis.framework.vortex.bufferzone.collectionName=jellyfish
atlantis.framework.vortex.bufferzone.pullSize=100

#Elasticsearch Configuration
spring.data.elasticsearch.cluster-name=es
spring.data.elasticsearch.cluster-nodes=localhost:9300
spring.data.elasticsearch.repositories.enabled=true
spring.data.elasticsearch.properties.transport.tcp.connect_timeout=60s

#Redis Configuration
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=123456
spring.redis.dbIndex=0

具体更具体的参数设置请参考:https://github.com/paganini20…

正文完
 0