allinurl / goaccess

GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
https://goaccess.io
MIT License
18.12k stars 1.1k forks source link

Need help with nginx ingress custom log format #2138

Closed stefanivic closed 3 years ago

stefanivic commented 3 years ago
$host - $remote_addr $remote_port - $remote_user [$time_local] [$msec] \"$scheme\" \"$request\" '
                              '$status $body_bytes_sent \"$http_referer\" '
                              '\"$http_user_agent\" \"$http_x_forwarded_for\" '
                              '\"$request_time\" \"$upstream_connect_time\" \"$upstream_response_time\" \"$http_accept_encoding\"'

This is the current setup. I tried to do:

--log-format='%v %^ %^ - - [%d:%t] %~ %~ %m %U %^ %s %b %R %u %^ %^ %^ %^ %^ %T %^
' --date-format=%d/%b/%Y --time-format='%H:%M:%S +0000'

But it fails with the date.

==29045== GoAccess - Copyright (C) 2009-2020 by Gerardo Orellana
==29045== https://goaccess.io - <hello@goaccess.io>
==29045== Released under the MIT License.
==29045==
==29045== FILE: access.log
==29045== Parsed 10 lines producing the following errors:
==29045==
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045== Token '[29/Jun/2021' doesn't match specifier '%d'
==29045==
==29045== Format Errors - Verify your log/date/time format
0bi-w6n-K3nobi commented 3 years ago

Hi @stefanivic

For short answer: Change for --time-format='%H:%M:%S' and use into --log-format the expression [%d:%t %^] rather than [%d:%t].

But, for more detail and safe CONF I ask if you can put here same lines.

0bi-w6n-K3nobi commented 3 years ago

For long answer: --log-format='%v - %^ %^ - %^ [%d:%t] [%^] "%^" "%r" %s %b "%R" "%u" "%^" "%^" "%^" "%T" "%^"' or --log-format='%v %^[%d:%t] [%^] "%^" "%r" %s %b "%R" "%u" "%^" "%^" "%^" "%T" "%^"' --time-format='%H:%M:%S'

and some Notes:

I hope I have helped you.

stefanivic commented 3 years ago

@0bi-w6n-K3nobi thanks, worked like a charm.