微服务请求量监控

有些时候,我们需要监控每个微服务或者集群,实时请求量和历史请求量走势,简单理解就是qps。

只支持bus服务端接口请求监控

服务端部署

安装influxdb数据库

更多influxdb文档请参考https://jasper-zhang1.gitbooks.io/influxdb/content/

准备

安装InfluxDB包需要root或是有管理员权限才可以。

网络

InfluxDB默认使用下面的网络端口:

  • TCP端口8086用作InfluxDB的客户端和服务端的http api通信

  • TCP端口8088给备份和恢复数据的RPC服务使用

  • 另外,InfluxDB也提供了多个可能需要自定义端口的插件,所以的端口映射都可以通过配置文件修改,对于默认安装的InfluxDB,这个配置文件位于/etc/influxdb/influxdb.conf

RedHat & CentOS

RedHat和CentOS用户可以直接用yum包管理来安装最新版本的InfluxDB。

cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF

一旦加到了yum源里面,就可以运行下面的命令来安装和启动InfluxDB服务:

sudo yum install influxdb
sudo service influxdb start

如果你的系统可以使用Systemd(比如CentOS 7+, RHEL 7+),也可以这样启动:

sudo yum install influxdb
sudo systemctl start influxdb

创建数据库

influxdb  #连接数据库

CREATE DATABASE monitordb #创建数据库

部署监控服务

部署安装包wueasy-bus-monitor-server-*.jar

修改配置:

wueasy: 
#  localIp : 192.0.0.1 #指定本机ip地址
  #zookeeper注册中心地址
  zk: 
    servers: 127.0.0.1:2181
    sessionTimeout: 3000
    connectionTimeout: 5000
  data:
    influxdb:
      monitor: 
        url: http://49.234.40.74:8086
        username: root
        password: root
        database: monitordb
  monitor: 
    websocket: 
      port: 9326 #端口
      accessAddress: ws://127.0.0.1:9326 #外网访问地址

需要特别注意,zk注册中心必须和客户端的一致

客户端使用

需要在客户端配置启用监控,配置后会自动从注册中心发现监控服务,默认不启动

wueasy: 
  bus: 
    monitor: 
      enable: true
Copyright © wueasy.com 2017-2021 all right reserved,powered by Gitbook未经允许,禁止以任何形式传播 修订时间: 2021-04-18

results matching ""

    No results matching ""