GoAccess is an open source, free web log analyzer that provides real-time analysis via web browser. It is fast and consumes very little memory. GoAccess is very popular and used by many website administrators around the world. In this article, we will look at how to install GoAccess Log Analyzer in Ubuntu.
How to Install GoAccess Log Analyzer in Ubuntu
Here are the steps to install GoAccess Log Analyzer in Ubuntu.
1. Update System
Open terminal and run the following commands to update Ubuntu system.
$ sudo apt-get update -y
2. Install GoAccess
GoAccess it not present in Ubuntu repository. You need to add its repository to your system with the following command.
First we download & add GPG key with the following command.
$ sudo wget -O - https://deb.goaccess.io/gnugpg.key | apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add -
Next, we add GoAccess repository with the following command.
$ sudo echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/goaccess.list
After the repository is added, run the following command to install GoAccess.
$ sudo apt-get update -y $ sudo apt-get install goaccess -y
3. Launch GoAccess
You can launch GoAccess from terminal by supplying the full path to your server log. In our example, we will use GoAccess to analyze Apache server log.
$ sudo goaccess /var/log/apache2/access.log --log-format=COMBINED
It will automatically parse the log file and display the results in a neat format.
Dashboard - Overall Analyzed Requests (29/Jun/2021 - 29/Jun/2021) [Active Panel: Visitors] Total Requests 16 Unique Visitors 6 Unique Files 1 Referrers 0 Valid Requests 16 Init. Proc. Time 0s Static Files 1 Log Size 4.44 KiB Failed Requests 0 Excl. IP Hits 0 Unique 404 2 Bandwidth 30.91 KiB Log Source /var/log/apache2/access.log > 1 - Unique visitors per day - Including spiders Total: 1/1 Hits h% Vis. v% Bandwidth Data ---- ------- ---- ------- ----------- ---- 16 100.00% 6 100.00% 40.91 KiB 29/Jun/2021 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 2 - Requested Files (URLs) Total: 1/1 Hits h% Vis. v% Bandwidth Mtd Proto Data ---- ------- ---- ------- ----------- --- -------- ---- 6 100.00% 5 100.00% 20.62 KiB GET HTTP/1.1 / 3 - Static Requests Total: 1/1 Hits h% Vis. v% Bandwidth Mtd Proto Data ---- ------- ---- ------- ----------- --- -------- ---- [?] Help [Enter] Exp. Panel 0 - Thu Jun 29 11:29:56 2021
Since the result contains a lot of information, you will need a few shortcuts to navigate the interface. Here are the shortcuts you can use.
F5 : Refresh the dashboard G : Move to the last item in the dashboard and use g to move to the top of the dashboard j and k : Scroll up and down s : Display sort options for the active module ? : Display help information TAB : Move forward q : Exit from the program
The output contains different sections containing different metrics. You may also use the following shortcuts to directly jump to relevant sections.
4. View web report
The above report is displayed in terminal. If you want to view an HTML, JSON, CSV report that can be accessed via web browser, run the following command
$ sudo goaccess /var/log/apache2/access.log --log-format=COMBINED -a -o /var/www/html/report.html
After you run the above command, open web browser and visit http://your-domain-or-ip/report.html. You will see the following kind of page.
That’s it. In this article, we have learnt how to install GoAccess Log Analyzer in Ubuntu.
How to Check Python Package Version
How to Install Go (Golang) in Ubuntu
How to Extract Substring from String in Ubuntu
How to Split String into Array in Shell Script
How to Check if String Contains Substring in Bash