Rhit-Nginx日志分析(可视化)

概述

Rhit 可以从标准文件夹中读取 Nginx 的日志文件(gzipped 的压缩文件也可以),并进行分析统计,在控制台中以可视化的表格形式展示,并且不会产生任何多余的临时文件或数据。

可以按照日期、响应值、请求来源等进行过滤匹配,并进行分析,Rhit 具有很高的效率,每秒可以处理百万行日志数据。

工具介绍


1
https://dystroy.org/rhit/


项目地址


1
https://github.com/Canop/rhit


下载地址


1
https://dystroy.org/rhit/download/


安装

环境

CentOS Linux 7 (Core)

1、下载


1
wget https://dystroy.org/rhit/download/rhit_1.4.1.zip


2、解压


1
unzip -o rhit_1.4.1.zip -d rhit/


3、切换目录

4、获取帮助文档


1
./rhit --help


使用

显示指定字段

工具会自动提取nginx存放日志的目录文件,也可指定存放目录。


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit ./access.log-20210308.gz


如下提取默认保存目录


123
[root@si1ent x86_64-unknown-linux-musl]# ./rhitI've read 11 files in "/var/log/nginx"9,303 hits and 1.7G from 2021/03/07 to 2021/03/17


参数


1234567891011
--color 默认是auto,可设置yes、或no来颜色区分.--help 获取帮助文档--length 获取更多详细信息(1~6级别默认为1)--fields 指显示字段信息:ip、method、等其他字段--date -d 日期--ip -i IP--method -m 请求方法--path -p 路径--referer -r 来源--status -s 状态码


显示每日请求


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit -f date


显示IP


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit -f ip


显示状态码


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit -f status


筛选IP


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit -i 221.225.31.88


筛选日期


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit  -d  2021/03/07-2021/03/08


其他高级筛选


1
[root@si1ent x86_64-unknown-linux-musl]# ./rhit -d 2021/03/07-2021/03/17 -p /tag


说明

其他参数适用请各位大佬继续发掘并结合其他工具使用。

Referer


12
https://github.com/Canop/rhithttps://dystroy.org/rhit/


本文出处:https://si1ent.xyz/2021/03/17/Rhit-Nginx%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90/