LOG.IO安装与配置

  • 简介

    log.io 是一个实时日志监控工具,每秒可以处理超过5000条日志消息,log.io 只监视日志变动并不存储日志。log.io 由两部分组成:server 和 harvester, server监视和纪录从harvester发来的日志消息,harvester 用来监听和收集日志改动,并将改动发送给server

  • 安装服务端
    # 安装依赖包
    yum install gcc gcc-c++ openssl-devel  pkgconfig -y
    # 安装nodejs
    wget https://nodejs.org/dist/v12.18.1/node-v12.18.1-linux-x64.tar.gz
    tar zxvf node-v12.18.1-linux-x64.tar.gz
    mv node-v12.18.1-linux-x64 /data/node
    ln -s /data/node/bin/node /usr/bin/node
    ln -s /data/node/bin/npm /usr/bin/npm
    ln -s /data/node/bin/npx /usr/bin/npx
    
    # 安装pm2
    npm install -g pm2
    # 安装log.io
    # npm install -g --prefix=/data/logio/ log.io --registry=https://registry.npm.taobao.org
    npm install -g log.io
    
    # 创建目录、配置文件(按实际情况修改)
    mkdir -p /root/.log.io
    vim /root/.log.io/server.json
    
    {
      "messageServer": {
        "port": 6689,
        "host": "127.0.0.1"
      },
      "httpServer": {
        "port": 6688,
        "host": "127.0.0.1"
      },
      "debug": false,
      "basicAuth": {
        "realm": "abc123xyz",
        "users": {
          "username1": "password1"
        }
      }
    }
    
    # 启动log.io-server
    pm2 start log.io-server
    pm2 save
    
    # 查看有无报错
    pm2 logs ID
  • 安装客户端
    # 安装nodejs、pm2
    略…
    
    #安装log.io-file-input
    npm install -g log.io-file-input
    
    # 创建目录、配置文件(按需修改)
    mkdir -p /root/.log.io/inputs
    vim /root/.log.io/inputs/file.json
    
    {
      "messageServer": {
        "host": "127.0.0.1",
        "port": 6689
      },
      "inputs": [
        {
          "source": "server1",
          "stream": "app1",
          "config": {
            "path": "log.io-demo/file-generator/app1-server1.log"
          }
        },
        {
          "source": "server2",
          "stream": "system-logs",
          "config": {
            "path": "/var/log/**/*.log",
            "watcherOptions": {
              "ignored": "*.txt",
              "depth": 99,
            }
          }
        }
      ]
    }
    
    # 启动log.io-file-input
    pm2 start log.io-file-input
    pm2 save
    
    # 查看有无报错
    pm2 logs ID
  • WEB页面查看

    访问地址:log.io-server配置文件中的httpServer信息

附:json格式验证地址

你可能感兴趣的:(日志日志分析实时刷新)