One of the first roles of any systems administrator is viewing and analyzing log files. internet server log files from alternative Apache and Nginx will build up over time and examining them will sway be a tedious and long activity. Thankfully, GoAccess will alleviate all that stress and change you to seamlessly monitor and analyze internet server log files.
Written in C Programming language, GoAccess is Associate in Nursing opensource, terminal-based period of time log analyser. It’s fast, interactive, and displays the logs in a sublime and intuitive fashion. It provides support for a large sort of log files as well as Apache, Nginx, Caddy, Amazon S3, and CloudFront to say simply many. It will render the ends up in HTML format, JSON, and conjointly generate a CSV report.
In this guide, we are going to specialise ina way to install goaccess and use it to research period of time Apache and Nginx net server logs.
GoAccess permits you to look atthe subsequent log metrics:
- Daily unique visitors
- Requested files
- Static requests ( jpg, pdf, png, mp4, avi, etc)
- Not found (404) requests
- Visitors’ hostname and IP details
- Visitor’s Operating system & browser details
- Geo Location
How to install GoAccess
There square measure 2 main ways that of putting in GoAccess on your UNIX/Linux operating system system. you’ll be able to either build from source or use your distribution’s package manager. Let’s inspect however you’ll be able to accomplish by doing each.
Install GoAccess on various distributions
Here’s how you can install GoAccess on various Linux distributions.
On Ubuntu / Debian distributions
If you are running Ubuntu or any Debian-based system, execute:
$ sudo apt install -y goaccess
On RHEL / CentOS
For RHEL and CentOS-distros, run the command:
$ sudo yum install -y goaccess or$ sudo dnf install -y goaccess
On Fedora, run the command:
$ sudo dnf install goaccess -y
On Arch Linux
For Arch Linux and other Arch-distros such as Arch Linux and Manjaro, run the command.
$ sudo pacman -S goaccess
For other distributions such as OpenSUSE and UNIX flavors such as FreeBSD, visit the official GoAccess download link.
Install GoAccess from source
To install from source, first, download the GoAccess tarball file using wget command
$ wget https://tar.goaccess.io/goaccess-1.4.6.tar.gz
Extract the tarball file with beneath tar command
$ tar -xvf goaccess-1.4.6.tar.gz
Then, navigate into the directory and build from source as shown.
$ cd goaccess-1.4.6/ $ ./configure --enable-utf8 --enable-geoip=mmdb $ make # make install
Verify the installation
To confirm that GoAccess has been installed, run the following command.
This will print or display the command usage and command options as shown.
In addition, you can check the version of GoAccess as shown.
$ goaccess --version
How to use GoAccess to Monitor Ream-Time Apache & Nginx logs
Once you have installed GoAccess, The next step is to monitor the web log files. In this example, we have the Apache web server installed and we are going to monitor the access.log file to view statistics on how clients are interacting with the web server from a browser.
The -f option allows you to view real-time the logs on the command line
$ goaccess -f /var/log/apache2/access.log --log-format=COMBINED
Your web server’s log statistics will be printed on the terminal including total requests, valid requests, valid visitors, unique files and so many more.
Be sure to scroll down to view other web server statistics such as Not Found 404 requests, visitor hostnames, and IP addresses.
Here, we have statistics on the operating systems and web browsers from which the visitors are accessing the web server.
To monitor Nginx logs, use the same drill as you did when monitoring Apache logs. Just switch to root user and run the command below.
# goaccess -f /var/log/nginx/access.log --log-format=COMBINED
View logs output on a web dashboard
You can also render the web server logs on elegant and intuitive dashboards by redirecting the output in an html file as shown. Here’s we have specified the output file as reports.html.
$ goaccess -f /var/log/apache2/access.log --log-format=COMBINED > reports.html
Next, open your web browser and browse the location of the file which will immediately render the logs in beautiful dashboards as shown.
GoAccess may be a useful gizmo that offers you heaps of insights regarding your net server’s interaction with guests on your web site. It permits you to get a wealth of careful info regarding visitors’ interaction along with your website which will prove helpful in reaching a wider audience and rising user expertise.