爱意满满的作品展示区。
fantastM

做了一个 Nginx 访问日志的分析工具

  •  
  •   fantastM · Nov 10, 2021 · 2822 views
    This topic created in 1671 days ago, the information mentioned may be changed or developed.

    可以简单地分析 Nginx 的 access.log ,不过需要用 log_format 加个 JSON 格式的日志文件,最终可以统计出一些有用的信息,比如 访问次数最多的接口(平均 /百分位)耗时最长的接口访问次数最多的国家和城市

    这个工具对我来说,最主要的用途就是替换类似这样繁琐的 shell 脚本:awk '{print $1}' access.log | sort | uniq -c | sort -nr | head -n 20,顺带做一些 shell 难以实现的功能。对于不想安装 ELK 、访问量不大的个人站长来说,或许是个有用的选择。

    项目地址是这个:README_ZH.md

    另外,我在写这个工具的时候,还发现了另一更强大和通用的 web 日志分析工具 https://goaccess.io/ ,给各位安利一下。

    4 replies    2021-11-11 20:05:24 +08:00
    whcoding
        1
    whcoding  
       Nov 10, 2021
    已 star 有时间试试~
    beshe
        2
    beshe  
       Nov 11, 2021
    看了之后,觉得还是 docker 版 ELK 好用。
    fantastM
        3
    fantastM  
    OP
       Nov 11, 2021 via iPhone
    @beshe 我也觉得 ELK 很好用,不过服务器只有 1 核 2G ,资源有限…
    jabari
        4
    jabari  
       Nov 11, 2021
    @fantastM #3 做日志收集
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   975 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:38 · PVG 03:38 · LAX 12:38 · JFK 15:38
    ♥ Do have faith in what you're doing.