您的位置:首页 > 运维架构 > Nginx

Nginx 日志分析工具 Goaccess

2016-08-26 17:18 281 查看
centos 6.7
1. 安装
$yum install goaccess

2.配置
根据nginx的日志规则

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

$vim /etc/goaccess.conf
time-format %H:%M:%S
date-format %d/%b/%Y
#log-format %^ %^[%d:%t %^] "%r" %s %b "%R" "%u" "%h" //使用cloudflare
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" "%^"

3.使用
$goaccess -f access.log

4.生成文件
$goaccess -f access.log -a > report.html

附 控制台操作
F1是打开帮助文档
F5是刷新当前窗口
q是退出当前窗口,直到退出程序
o是进入选择条目
0-9 是选择模块
tab和shift+tab是在前后模块之前切换
j和k是在模块内部条目切换
s是模块内部条目排序方式

ps:模块切换在右上角有当前模块的标示

其他配置



goaccess支持排序!这样你就可以tab到request这个模块,而后按s,
跳出来的对话框选择“Time Serverd” “DESC” 这样你就可以非常清楚的知道你的网站是哪些页面响应很慢了!
NGINX日志格式:

log_format main ’$remote_addr – $remote_user [$time_local] “$request” ‘

‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $request_time‘;

配置:
color_scheme 0
date_format %d/%b/%Y
log_format %h %^[%d:%^] “%r” %s %b “%R” “%u” %T

官网详细说明:https://goaccess.io/man
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: