GunnerFan
GunnerFan

Reputation: 4047

How to monitor nginx error logs with Goaccess?

Most goaccess examples are for monitoring access logs. I want to monitor error logs with goaceess.

My error logs are of the following format:

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"

Right now I am using the following log format:

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

However, the goaccess report is not generating a useful output. I would like to see the details of each type of error in the report.

Upvotes: 3

Views: 2292

Answers (2)

Pablo Bianchi
Pablo Bianchi

Reputation: 2038

nginx 1.18, GoAccess - 1.4, assuming locale en_US.UTF-8

https://goaccess.io/man#examples

For access.log

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

On /etc/goaccess.conf (system-wide) or ~/.goaccessrc (user-wide)

Or in one line and with '%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

For error.log

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

Source.

Upvotes: 0

ZeDesigner
ZeDesigner

Reputation: 11

In my server this is the working Regexp

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

Upvotes: 1

Related Questions