goaccess
goaccess copied to clipboard
Convert nginx json log elements to goaccess
This is my nginx json format
log_format main escape=json
'{'
'"time_local":"$time_local",'
'"remote_addr":"$remote_addr",'
'"remote_user":"$remote_user",'
'"request_method":"$request_method",'
'"request_uri":"$request_uri",'
'"server_protocol":"$server_protocol",'
'"status": "$status",'
'"body_bytes_sent":"$body_bytes_sent",'
'"request_time":"$request_time",'
'"http_referrer":"$http_referer",'
'"http_user_agent":"$http_user_agent",'
'"http_x_forwarded_for": "$http_x_forwarded_for",'
'"request_id": "$request_id",'
'"requested_domain": "$host"'
'}';
And here is the ouput of the nginx log
{"time_local":"11/Jul/2021:03:13:10 +0200","remote_addr":"192.168.0.1","remote_user":"","request_method":"OPTIONS","request_uri":"/api/example_services?filter=%7B%22where%22:%7B%22deactivated%22:false%7D%7D","server_protocol":"HTTP/2.0","status": "204","body_bytes_sent":"0","request_time":"0.023","http_referrer":"https://example.domain.org/","http_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1","http_x_forwarded_for": "","request_id": "e40ae239c4e0a521352132d4fde693c1","requested_domain": "example.domain.org"}
goaccess version GoAccess - 1.5.1. For more details visit: https://goaccess.io/ Copyright (C) 2009-2020 by Gerardo Orellana
Build configure arguments: --enable-utf8 --enable-geoip=legacy
Can I convert it to let goaccess to be able to read it and put it out to report.html?
This should do it:
goaccess access.log --log-format='{"time_local": "%d:%t %^", "remote_addr": "%h", "remote_user": "%e", "request_method": "%m", "request_uri": "%U", "server_protocol": "%H", "status": "%s", "body_bytes_sent": "%b", "request_time": "%T", "http_referrer": "%R", "http_user_agent": "%u", "requested_domain": "%v"}' --date-format=%d/%b/%Y --time-format=%T