Hello, friends. In this post, you will learn how to install GoAccess on Ubuntu 20.04. This way you will be able to monitor your web server without problems.
What is it?
According to the project’s website,
GoAccess is an open source real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Also, “It provides fast and valuable HTTP statistics for system administrators that require a visual server report on the fly”.
Some features are:
- Fast, real-time, millisecond/second updates, written in C
- Only ncurses as a dependency
- Nearly all web log formats (Apache, Nginx, Amazon S3, Elastic Load Balancing, CloudFront, etc)
- Simply set the log format and run it against your log
- Beautiful terminal and bootstrap dashboards (Tailor GoAccess to suit your own color taste/schemes)
- and of course, Valgrind tested.
Installing GoAccess on Ubuntu 20.04
GoAccess is available in the official Ubuntu repositories, so the installation is quite simple but it is convenient to have the latest version available. So, you have to add the GoAccess repository.
To do this, open a terminal and execute the following commands:
echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add -
Now refresh the APT cache:
sudo apt update
And performs the installation running:
sudo apt install goaccess Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: linux-headers-5.4.0-26 linux-headers-5.4.0-26-generic linux-image-5.4.0-26-generic linux-modules-5.4.0-26-generic linux-modules-extra-5.4.0-26-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: libncursesw5 libtinfo5 The following NEW packages will be installed: goaccess libncursesw5 libtinfo5 0 upgraded, 3 newly installed, 0 to remove and 53 not upgraded. Need to get 535 kB of archives. After this operation, 1889 kB of additional disk space will be used. Do you want to continue? [Y/n]
If you want, you ca check the installed version:
GoAccess - 1.4. For more details visit: http://goaccess.io Copyright (C) 2009-2020 by Gerardo Orellana
And so you can get GoAccess, now let’s use it a little.
Using GoAccess on Ubuntu 20.04
The first thing you can do is check the help that the terminal gives us, for that you can run:
On the other hand, the most basic way to use goaccess is simply by specifying a log file.
Or you can select the log of your Virtualhost.
There you will be shown a screen in the terminal where you can choose the log output format.
In my case, I have chosen the third option (CLF).
And immediately it will start the analysis.
Note: I am working with a home test server. Therefore, there is not so much activity in the log.
But you can also specify a log format to make it work with, for example, squid. Although we recommend that you read the official documentation
A very interesting option is to display it directly on your web browser. I think this is the best possible option.
sudo goaccess /var/log/apache2/access.log --log-format=COMBINED -a -o /var/www/html/file.html
And this will generate a file that you can open from the browser. Remember to modify the name of the output file.
And this is the basic use of GoAccess as we see is a basic but very useful tool.
Having a program that can analyze logs graphically and interactively is an advantage for all of us who work on Linux. That’s why today we wanted to show you GoAccess.