ngxtop作为分析nginx日志一个很重要的工具,记录一些相关的使用和命令部分
1 | ngxtop --help |
一些说明:
Options:
1 | -l <file>, --access-log <file> access log file to parse |
指定access log
1 | -f <format>, --log-format <format> log format as specify in log_format directive. [default: combined] |
指定 log format
1 | --no-follow ngxtop default behavior is to ignore current lines in log and only watch for new lines as they are written to the access log. Use this flag to tell ngxtop to process the current content of the access log instead |
ngxtop默认会对accesslog的新增行进行统计, 通过这个选项可以让ngxtop统计旧log
1 | -t <seconds>, --interval <seconds> report interval when running in follow mode [default: 2.0] |
1 | -g <var>, --group-by <var> group by variable [default: request_path] |
基于字段分组
1 | -w <var>, --having <expr> having clause [default: 1] |
分组之后再筛选
1 | -o <var>, --order-by <var> order of output for default query [default: count] |
排序字段
1 | -n <number>, --limit <number> limit the number of records included in report for top command [default: 10] |
默认显示前多少条
1 | -a <exp> ..., --a <exp> ... add exp (must be aggregation exp: sum, avg, min, max, etc.) into output |
对输出字段做附加条件 sum/avg/min/max 可选
1 | -v, --verbose more verbose output |
Advanced / experimental options:
1 | -c <file>, --config <file> allow ngxtop to parse nginx config file for log format and location |
指定nginx config文件,ngxtop 会自动解析配置文件,分析出access log的位置以及格式
1 | -i <filter-expression>, --filter <filter-expression> filter in, records satisfied given expression are processed |
常用的一些demo:
1 | ngxtop -l nginx.log |