How to Install GoAccess Web Log Analyzer on Ubuntu 20.04

Linux

Preface

GoAccess is a free and open-source weblog analyzer tool used for the analysis of logs in real-time. You can analyze logs through a web browser or terminal. It is fast and light-weight that cannot consume a large amount of your CPU and Memory. It uses Common Log Format to parses and analyzes the web server logs. It supports HTTP/2 & IPv6 and has the ability to output JSON and CSV.

GoAccess provides very useful statistics to system administrators including, top visitors, bandwidth, referring sites and URLs, operating systems, IP location, reverse DNS, geolocation, HTTP status code, and much more.

In this tutorial, we will show you how to install and use GoAccess on Ubuntu 20.04.

Prerequisites

  • A server running Ubuntu 20.04.
  • A root password is configured the server.

Getting Started

Before starting, you will need to update your system packages to the latest version. You can update them using the following command:

apt-get update -y

Once your server is updated, you can proceed to the next step.

Install GoAccess from Ubuntu Repository

By default, GoAccess is not included in the Ubuntu default repository. So you will need to add the GoAccess repository to your system.

First, download and add the GPG key with the following command:

wget -O - https://deb.goaccess.io/gnugpg.key | apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add -

Next, add the GoAccess repository with the following command:

echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/goaccess.list

Once the repository is added, update the repository cache and install the GoAccess with the following command:

apt-get update -y
apt-get install goaccess -y

This will install the GoAccess to your system.

Install GoAccess From Source

You can also install the GoAccess by compiling it from the source. First, you will need to install the required dependencies with the following command:

apt-get install libncursesw5-dev libgeoip-dev libtokyocabinet-dev build-essential -y

Once all the dependencies are installed, download the GoAccess source with the following command:

wget http://tar.goaccess.io/goaccess-1.4.tar.gz

Once the download is completed, extract the downloaded file with the following command:

tar -xzvf goaccess-1.4.tar.gz

Next, change the directory to extracted directory and configure GoAccess with the following command:

cd goaccess-1.4/
./configure --enable-utf8 --enable-geoip=legacy

You should get the following output:

Your build configuration:

  Prefix         : /usr/local
  Package        : goaccess
  Version        : 1.4
  Compiler flags :  -pthread
  Linker flags   : -lnsl -lncursesw -lGeoIP -lpthread  
  UTF-8 support  : yes
  Dynamic buffer : no
  Geolocation    : GeoIP Legacy
  Storage method : In-Memory with On-Disk Persitance Storage
  TLS/SSL        : no
  Bugs           : [email protected]

Next, install the GoAccess to your system using the following command:

make 
make install

Once the installation has been finished, you can verify the installed version of GoAccess with the following command:

goaccess --version

You should get the following output:

GoAccess - 1.4.
For more details visit: http://goaccess.io
Copyright (C) 2009-2020 by Gerardo Orellana

Build configure arguments:
  --enable-utf8
  --enable-geoip=legacy

You can find the GoAccess default configuration file with the following command:

goaccess --dcf

You should see the following output:

/usr/local/etc/goaccess/goaccess.conf

Launch GoAccess Dashboard

Open your terminal launch the GoAccess dashboard using the following command:

goaccess /var/log/apache2/access.log --log-format=COMBINED

You should see the following screen:

You can use the following keyboard shortcuts to navigate the interface:

F5 : Used to refresh the dashboard.
G : Used to move to the last item in the dashboard and use g to move to the top of the dashboard.
j and k : Used to scroll up and down.
s : Used to display the sort options for the active module.
? : Used to display help information.
TAB : Used to move forward.
q : Used to exit from the program.

Now, press 1 to display the unique visitors, bandwidth, and total hits per day as shown below:Advertisement

display the unique visitors, bandwidth, and total hits per day

Press 2 to display the most highly requested non-static files on your web server as shown below:

Display the mostly requested non-static files

Press 3 to display the information about static files such as images, CSS, JavaScript as shown below:

Images, CSS and JavaScript

Press 4 to display the path not found URLs as shown below:

404 Statistics

Press 5 to display the hostname and IP address of the visitor as shown below:

hostname and IP address

Press 6 to display the information of the operating system used by hosts as shown below:Advertisement

Information of the operating system used by host

Press 7 to display the information of each unique visitor as shown below:

unique visitor stats

Press 8 to display the hourly information of the number of hits, unique visitors, and bandwidth consumed as shown below:

number of hits, unique visitors, and bandwidth

Generate an HTML Report

GoAccess also allows you to generate an HTML, JSON, or CSV reports and access it through the web browser.

You can generate it with the following command:

goaccess /var/log/apache2/access.log --log-format=COMBINED -a -o /var/www/html/report.html

Now, open your web browser and access the generated report using the URL http://your-server-ip/report.html.

You should see the following page:

Goaccess HTML report

Conclusion

In this post, you learned how to install and use GoAccess to analyze your Apache web server logs. You can also use this tool for Nginx, Amazon S3, Elastic Load Balancing, and CloudFront. Feel free to ask me if you have any questions.

Hope this helps!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *