Use the document reference address:
https://my.oschina.net/mrco/blog/181737
Https://www.fanhaobai.com/2017/06/go-access.html
Goaccess Address: Https://goaccess.io/download
Download the goaccess for the CENTOS7 version
Before installation, you need to enable Log_format in Nginx and configure the following format
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
"$http _user_agent" "$http _x_forwarded_for" "$request _body";
1) Install dependent packages
Yum-y Install glib2 glib2-devel ncurses ncurses-devel GeoIP geoip-devel
2) Install Goaccess
wget http://tar.goaccess.io/goaccess-1.2.tar.gz
TAR-XZVF goaccess-1.2.tar.gz
CD GOACCESS-1.2/
#如果是https, you need to turn on--with-openssl
./configure--enable-utf8--enable-geoip=legacy--with-openssl
Make
Make install
3) Move configuration file
The default profile is installed in/usr/local/etc/goaccess.conf and the files are moved to the ETC directory
mv/usr/local/etc/goaccess.conf/etc/
Modify the contents of the goaccess.conf in the configuration file
Time-format%h:%m:%s
Date-format%d/%b/%y
Log-format%h%^[%d:%t%^] "%r"%s%b "%r" "%u"
Log-format corresponds to Access.log log_format format, each parameter has a space or tab spacing
Goaccess.conf the meaning of each configuration:
%t matching Time fields in Time-format format
%d date fields that match the Date-format format
%H Host (client IP address, including IPv4 and IPv6)
%r request lines from the client
%m Method of Request
%u URL Path
%H Request Agreement
Status code for%s server response
%b the content size returned by the server
%R the Referer field of the HTTP request header
%u HTTP request header for user agent
%d The time spent in the request, in microseconds
%T the time spent in a request, per second
%^ Ignore this field
4) Start goaccess
Goaccess-a-d-f/var/log/nginx/access.log-p/etc/goaccess.conf
$ goaccess-h
# Common Parameters
-A--agent-list is enabled by the Host User agent list. For faster parsing, this key is not enabled
-D--with-output-resolver IP parsing in html/json output, IP parsing using GeoIP
-F--log-file log file path to parse
-P--config-file configuration file path
-o--output output format, supports HTML, JSON, CSV
-M--with-mouse Control Panel supports mouse click
-Q--no-query-string Ignore the requested parameters section
--real-time-html generating HTML reports in real time
--daemonize daemon mode,--real-time-html when used
Add these parameters to view the data in real time:--real-time-html--daemonize
Use WebSocket to listen for 7890 ports by default, plus parameter--port
If you need to enable SSL, you will need to modify Ssl-cert Ssl-key in the configuration file goaccess.conf, use the protocol WSS and modify Ws-url to: wss://www.domain.com
F1 main help Page
F5 Redraw the main window
Q exit
1-15 jump to the module location of the corresponding number
o Open a detailed view of the current module
J Current Module Scroll down
K Current module Scroll up
S to sort the modules
/search for matches in all modules
N finding where the next occurrence occurs
G move to the top of the first module
G move to the bottom of the last module
5) Generate logs using timed tasks:
# Timed Task Content
0 0 1 * * goaccess-a-d-f/var/log/nginx/access.log-p/etc/goaccess.conf-o/var/log/nginx/goaccess.html 2>/var/log /nginx/goaccess.log
Introduction to installation and use of goaccess