Log Analysis w/ Nginx Virtual Hosts

Does anyone have an access_log format for nginx that works with multiple virtual hosts? I’ve tried a few different setups:

log_format combined_vhost_log
’$remote_addr - $server_name - $remote_user [$time_local] “$request” ‘
’$status $body_bytes_sent “$http_referer” ‘
’"$http_user_agent"’;

log_format combined_vhost_log
’ $server_name - $remote_addr - $remote_user [$time_local] “$request” ‘
’$status $body_bytes_sent “$http_referer” ‘
’"$http_user_agent"’;

Both of those are giving me invalid log lines when I specify the log format as common_vhost. It’s also unable to auto-detect a format.

This is the log format we ended up going with:

log_format vhosts ‘$host $remote_addr - $remote_user [$time_local] “$request” $status $body_bytes_sent “$http_referer” “$http_user_agent”’;

It seems to be working for now.

Interesting, could you please post the Log format name and format, in: Log analytics list of improvements · Issue #3163 · matomo-org/matomo · GitHub

we would be happy to add it to the list of supported segments!

Matt,

We’re using that format setup in Nginx and it matches your common_complete parser. Nothing you guys needed to do, it was just a matter of finding out what to setup for the nginx logs.

OK so maybe we could add this to the README though? please suggest a new README patch? :slight_smile:

Matt,

Not a problem, submitted an updated to the README:

http://dev.piwik.org/trac/attachment/ticket/3163/README_nginx_log_format.diff