0

I am running Nginx with installed Nginx Amplify. To get better metrics I've extend access log format to:

log_format  main_ext  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" '
                      '"$host" sn="$server_name" '
                      'rt=$request_time '
                      'ua="$upstream_addr" us="$upstream_status" '
                      'ut="$upstream_response_time" ul="$upstream_response_length" '
                      'cs=$upstream_cache_status' ;

Above format is from official Amplify documentation.

Everything works fine, extended metrics are included in Amplify web panel.

For better access log readibilty I also installed GoAccess package. When I start GoAccess with COMBINED log format it works. But I have configured few virtual hosts (that aren't show in GoAccess report page for now), so I should use VCOMBINED format, but it produces an error:

Token '+0100]' doesn't match specifier '%h'

To make it worked I've changed command to:

sudo goaccess /var/log/nginx/access.log \
        --log-format=VCOMBINED \
        --date-format=%d/%b/%Y --time-format=%T \
        -o /var/www/stats/report.html \
        --real-time-html

but same error appear. I have no idea how to create valid log pattern to work with amplify and GoAccess with virtual hosts support. I'm tried some tricks with awk but no luck.

Daniel
  • 101
  • 3

1 Answers1

0

main_ext log format is something made up by Nginx Amplify, it is not VCOMBINED.

This should perhaps work for you

time-format %T %z
date-format %d/%b/%Y

log-format if you don't use a CDN or load balancers

log-format %h %^ %^ [%d:%t] "%r" %s %b "%R" "%u" "%^" "%^" sn="%v" rt=%T %^

log-format if you are behind a CDN or load balancers

log-format %^ %^ %^ [%d:%t] "%r" %s %b "%R" "%u" "%h" "%^" sn="%v" rt=%T %^
Raboo
  • 103
  • 5