Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Tutorials»GoAccess – A Real Time Apache & Nginx Log Analyzer

    GoAccess – A Real Time Apache & Nginx Log Analyzer

    RahulBy RahulMarch 27, 20213 Mins ReadUpdated:March 27, 2021

    GoAccess is a real-time log analyzer for web server on Unix/Linux systems. It alos allows to access logs via the web browser. The main purposes is to allow users to provide a quick way to analyze and view web server statistics in real time without needing a web browser.

    It supports most of the web log formats (Apache, Nginx, Amazon S3, Elastic Load Balancing, CloudFront, Caddy, etc). You just need to set the log format and use. GoAccess also generates a complete, self-contained real-time HTML report, which is helpful for analytics, monitoring and data visualization. It also support JSON and CSV reports.

    This tutorial describes you to how to install and use GoAccess on your Linux systems.

    Installing GoAccess

    Most of the Linux operating systems contains GoAccess packages in their official repositories. So you can simply install it with package manager.

    • Debian based systems:
      sudo apt-get update && sudo apt-get install goaccess -y
      
    • Redhat based systems:
      yum install goaccess
      
    • Arch Linux:
      pacman -S goaccess
      

    For other operating systems visit this page to install Goaccess.

    Use GoAccess from Terminal

    Choose the log file based on your operating system and web server used. On Debian based systems log are generated under /var/log/apache2 directory and Redhat based system Apache create logs under /var/log/httpd directory. Use -f option to define the log file with goaccess command.

    goaccess -f /var/log/apache2/access.log
    

    Then select the log format. Default Apache log format is COMBINED.
    GoAccess Select Log format

    The GoAccess also allows you to define the log format with using --log-format command line options. For example, to use COMBINED log format the command will be:

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

    You will see the output on system console like below:

    GoAccess with Apache Logs

    Press ‘Q’ to exit out of the GoAccess terminal viewer.

    View GoAccess Output in Web Dashboard

    GoAccess allows users to generate report in various formats like HTML, JSON and CSV. The HTML format generates a html page with all data in visual format. We can generate the report by using the following command in to a html file.

    Let’s create a html report file under /var/www/html, which is the default document root set on my Apache server. The following command will generate html report:

    sudo goaccess /var/log/apache2/access.log --log-format=COMBINED -a -o /var/www/html/report.html
    
    • -a – Enable a list of user-agents by host
    • -o – Used to define output file
    • Output format is automatically selected based on output filename extension

    Next, access report.html using server ip address or domain name.

    Goaccess web dashboard

    Slide down to the webpage to display more information.

    Auto Update Web Dashboard File

    You can schedule goaccess command to update html report on regular interval. Create a shell script with following content:

    /opt/goaccess.sh:

    1
    2
    #!/bin/bash
    sudo goaccess /var/log/apache2/access.log --log-format=COMBINED -a -o /var/www/html/report.html

    Then schedule the above script with crontab:

    sudo crontab -e
    

    Add the following content to end of file

    #Cron job to update Goaccess HTML repot
    * * * * * /opt/goaccess.sh
    

    Save crontab and close.

    Conclusion

    In this tutorial, you have learned abount GoAccess utility to view web server logs in visual formats.

    Goaccess
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Tomcat 10 on Debian 10
    Next Article How To Install Google Cloud SDK on Debian 10

    Related Posts

    What is the /etc/aliases file

    2 Mins Read

    What is the /etc/nsswitch.conf file in Linux

    2 Mins Read

    How to Setup Squid Proxy Server on Ubuntu and Debian

    Updated:June 17, 20225 Mins Read

    How to Delete a Let’s Encrypt Certificate using Certbot

    Updated:June 3, 20222 Mins Read

    How to Install Latest Git on Ubuntu 22.04

    Updated:May 31, 20222 Mins Read

    How To Install LibreOffice on Ubuntu 22.04

    Updated:May 23, 20222 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.