This article describes how Nginx uses GoAccess to view Nginx access logs.

Recently, I learned about GoAccess monitoring tool while watching geek time – 100 Lectures on Nginx Core Knowledge video, so I have studied this tool recently, so I write this article.

1. GoAccess profile

GoAccess is an open source real-time web log analyzer and interactive viewer that can run on Linux systems or terminals through a browser. It provides quick and valuable HTTP statistics for system administrators who need dynamic visual server reporting.

Official website: goaccess.io/

Official website homepage:

Feature page (using Google Browser translation), I feel that the translation here is generally understandable, I will not write out a.

2. Install GoAccess

To download the official document, goaccess. IO/Download

As shown in figure:

Install the GoAccess dependency first. If it has been installed, ignore it.

The ncurses – devel:

yum install ncurses-devel
Copy the code

Tokyocabinet – devel:

yum install tokyocabinet-devel
Copy the code

Openssl devel: –

yum install openssl-devel
Copy the code

Geoip – devel:

yum install GeoIP-devel.x86_64
Copy the code

Then follow the steps of the official website, as follows: Download GoAccess

Wget HTTP: / / https://tar.goaccess.io/goaccess-1.2.tar.gzCopy the code

Unpack the

Tar - XZVF goaccess 1.2. Tar. GzCopy the code

Enter the directory

cdGoaccess - 1.2 /Copy the code

Generate the Makefile in preparation for the next step

./configure --enable-utf8 --enable-geoip = legacy
Copy the code

compile

make
Copy the code

The installation

make install
Copy the code

Use 3.

Here is a reference to tao Hui’s command used in the course, as follows

goaccess /opt/nginx/logs/access.log -o /opt/nginx/goaccess/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d/%b/%Y' --log-format=COMBINED 
Copy the code

The/opt/nginx/logs/access log for nginx log position, / opt/nginx/goaccess/report. The location for the generated HTML page, COMBINED the default file format specified, real – time – HTML HTML in real time.

Add the following configuration to the server in Nginx:

location /report.html {
       alias /opt/nginx/goaccess/report.html;
}
Copy the code

Restart Nginx, access localhost: 8080 / report. HTML can be seen as shown:

4. To summarize

The tools are powerful and can be used for real-time analysis in context.