如何使用Goaccess监控nginx错误日志?

yrdbyhpb  于 5个月前  发布在  Nginx
关注(0)|答案(2)|浏览(73)

大多数goaccess的例子都是用来监控访问日志的,我想用goaceess监控error日志。
错误日志的格式如下:

2020/02/05 09:23:08 [crit] 9711#9711: *6 SSL_do_handshake() failed (SSL: error:1420918C:SSL routines:tls_early_post_process_client_hello:version too low) while SSL handshaking, client: X.X.X.X, server: 0.0.0.0:443
2020/02/05 09:38:21 [error] 10106#10106: *3 directory index of "/var/www/example/public_html/" is forbidden, client: 162.158.166.216, server: example.com, request: "GET /nginx-reports/ HTTP/1.1", host: "example.com"

字符串
现在我使用以下日志格式:

log-format %d %t %^, client: %h, server: %^, request: "%r", host: "%v"


然而,goaccess报告并没有生成有用的输出。我想在报告中看到每种错误的详细信息。

llycmphe

llycmphe1#

在我的服务器中,这是工作的Regexp

log-format %d %t %^, client: %h, server: %^, request: "%r", host: "%v", referrer: "%R"

字符串

uujelgoq

uujelgoq2#

在此基础上,我们将使用一个新版本的GoAccess。
https://goaccess.io/man#examples

适用于access.log

log_format %h %^[%d:%^] "%r" %s %b "%R" "%u" %T
date_format %d/%b/%Y
time_format %H:%M:%S

字符串
/etc/goaccess.conf(系统范围)或~/.goaccessrc(用户范围)上
或在一行中,使用'%T'

goaccess access.log --log-format='%h %^[%d:%^] "%r" %s %b "%R" "%u" %T' --date-format='%d/%b/%Y' --time-format=%T


Source的一个。
Or just

goaccess access.log --log-format=COMBINED

适用于error.log

goaccess error.log --log-format='%d %t %^"%^" %^ %^: %h, %^: %v, %^: "%r" %^' --date-format=%Y/%m/%d --time-format=%T


源头

相关问题