zoukankan      html  css  js  c++  java
  • GoAccess日志分析

    1.GoAccess日志分析
    1.1简介

    GoAccess是一个开源的实时网络日志分析器和交互式查看器,可在Linux终端或浏览器中运行。

    1.2 软件功能

     – 为系统管理员提供可视化的服务器报告

    -为系统管理员提供快速且有价值的HTTP统计

    1.3软件特性

    – 快速、实时(由于基于C语言编写,可在毫秒或秒内完成更新)

    – 只依赖于ncurses

    – 兼容几乎所有的Web日志格式(Apache、Nginx、Amazon S3、Elastic Load Balancing、CloudFront等)

    – 只需要配置日志格式即可运行

    – 美丽的终端和引导仪表板(可自定义色彩方案)

    2、话不多说开始安装

    1)环境基于Docker容器运行7U机器

    2.1 安装GoAccess

    $ wget https://tar.goaccess.io/goaccess-1.3.tar.gz

    $ tar -xzvf goaccess-1.3.tar.gz $ cd goaccess-1.3/

    $ ./configure --enable-utf8 --enable-geoip=legacy

    $ make && make install

     

     FAQ:

    根据错误提示解决依赖关系:

     configure: error:

    *** Missing development files for the GeoIP library

    安装需要的软件包:

     yum install -y GeoIP-devel

     再次运行预编译命令并根据错误提示解决依赖关系:

     configure: error:

    *** Missing development libraries for ncursesw

    安装需要的软件包:

     yum install -y ncurses-devel

     

    2.2使用GoAccess分析日志

     PS:本次分析日志为tsar.data 标准输出日志

    日志格式选为 NCSA Combined Log Format

     

    回车即可看到当前日志分析结果

    控制台下的操作方法:

    F1 主帮助页面

    F5 重绘主窗口

    q 退出

    1-15 跳转到对应的模块编号

    o 打开当前模块的详细试图

    j 当前模块向下滚动

    k 当前模块向上滚动

    s 对模块排序

    ff1 主帮助页面asdg

    2.3 生成HTML页面

     

    查看当前配置

    [root@test1.inc.alipay.net /var/log]

    #egrep -v "^#|^$" goaccess.conf

    config-dialog false

    hl-header true

    json-pretty-print false

    no-color false

    no-column-names false

    no-csv-summary false

    no-progress false

    no-tab-scroll false

    with-mouse false

    agent-list false

    with-output-resolver false

    http-method yes

    http-protocol yes

    no-query-string false

    no-term-resolver false

    444-as-404 false

    4xx-to-unique-count false

    all-static-files false

    double-decode false

    ignore-crawlers false

    crawlers-only false

    ignore-panel REFERRERS

    ignore-panel KEYPHRASES

    real-os true

    static-file .css

    static-file .js

    static-file .jpg

    static-file .png

    static-file .gif

    static-file .ico

    static-file .jpeg

    static-file .pdf

    static-file .csv

    static-file .mpeg

    static-file .mpg

    static-file .swf

    static-file .woff

    static-file .woff2

    static-file .xls

    static-file .xlsx

    static-file .doc

    static-file .docx

    static-file .ppt

    static-file .pptx

    static-file .txt

    static-file .zip

    static-file .ogg

    static-file .mp3

    static-file .mp4

    static-file .exe

    static-file .iso

    static-file .gz

    static-file .rar

    static-file .svg

    static-file .bmp

    static-file .tar

    static-file .tgz

    static-file .tiff

    static-file .tif

    static-file .ttf

    static-file .flv

     

     由上可见默认配置中并无时间参数,需要在配置中添加时间参数。

    [root@test1.inc.alipay.net]

    #cat >>goaccess.conf<<EOF

    > time-format %H:%M:%S

    > date-format %d/%b/%Y

    > #NCSA Combined Log Format

    > log-format %h %^[%d:%t %^] "%r" %s %b "%R""%u"

    > EOF

     

    [root@test1.inc.alipay.net]

    #cp -a goaccess.conf ../

     

    2.4 crontab生成定时任务

    在某些场景下,没有这样的实时性要求,可采用 crontab 机制实现定时更新 HTML 报表。

    # 每天执行

    0 0 1 * * goaccess -a -d -f /data/logs/fanhaobai.com.access.log -p /etc/goaccess.conf -o /data/html/hexo/public/go-access.html 2> /data/logs/go-access.log

     TOP:官方文档:https://goaccess.io/man

    2.5 检查生产页面
     
    2.6 GoAccess高级阶段

    尽管 GoAccess 很强大,但是它无法制定自定义监控规则,无法满足对站点更细粒度更全面的监控需求。到 2018 年底,另站已经使用 ELK 日志平台 来分析站点的访问情况和流量分析了,效果见 ELK 集中式日志平台。

     

     

  • 相关阅读:
    Java
    hadoop MapReduce Yarn运行机制
    在eclipse上开发hadoop2.5.2程序的快捷方法
    eclipse快捷键
    HDFS原理介绍
    Java异常
    hadoop初识
    操作系统学习---进程管理(二)
    操作系统学习---进程管理(一)
    操作系统学习---虚拟内存
  • 原文地址:https://www.cnblogs.com/sseban/p/10185271.html
Copyright © 2011-2022 走看看