Back to articles
AI & Cloud

Real-Time Nginx Access Log Analysis on Terminal with GoAccess: A Lightweight Monitoring Solution for Enterprises

A detailed guide on analyzing real-time Nginx access logs on the terminal using GoAccess—a lightweight web monitoring tool ideal for mid-sized businesses. With a intuitive CLI...

DPTCloud Engineering4 min read
Real-Time Nginx Access Log Analysis on Terminal with GoAccess: A Lightweight Monitoring Solution for Enterprises

Introduction to GoAccess and Nginx Access Logs

GoAccess is a command-line (CLI) web log analyzer designed for real-time analysis of Nginx, Apache, and other common log formats. Unlike heavy monitoring solutions such as Grafana or ELK Stack, GoAccess operates with minimal system resources, making it ideal for mid-sized enterprises or VPS environments with limited RAM and CPU.

Nginx access logs contain detailed information about each request to the server: timestamp, remote IP address, HTTP method, status code, response time, accessed URL, user agent, and more. Analyzing these logs helps monitor performance, detect attacks, optimize content delivery, and understand user behavior.

Optimizing Monitoring with GoAccess on Terminal

GoAccess provides a visual CLI interface that allows users to view real-time reports without installing a web interface or database. Below are the steps to deploy and use GoAccess.

1. Install GoAccess

On Ubuntu/Debian systems, install GoAccess using APT:

sudo apt update
sudo apt install goaccess -y

For other operating systems, use the appropriate package manager or build from source.

2. Analyze Nginx Logs in Real Time

GoAccess can read logs directly from files or monitor log files as they are written. Use the following command to analyze Nginx logs in the standard combined format:

goaccess /var/log/nginx/access.log --log-format=COMBINED --real-time-html --port=7890

To monitor logs in real time and display results directly in the terminal:

goaccess /var/log/nginx/access.log --log-format=COMBINED --real-time

To customize the log format, check the Nginx configuration in /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf. The combined log format is defined as:

log_format combined '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" "$http_user_agent"';

3. Display Real-Time Reports

GoAccess supports multiple display options, including:

  • HTTP status code statistics (200, 404, 500)
  • Top accessed URLs
  • Top IP addresses generating traffic
  • Average response time
  • Browser and operating system breakdown

Run the following command to open the real-time report in the terminal:

goaccess /var/log/nginx/access.log --log-format=COMBINED --real-time

Navigate between pages using arrow keys or press q to exit.

Advantages and Use Cases

GoAccess is a lightweight monitoring solution suitable for:

  • Mid-sized businesses with VPS or dedicated servers with limited resources
  • System administrators needing quick web performance monitoring
  • Detecting issues or attacks such as DDoS, bots, or unauthorized access
  • Testing or developing small web applications

Compared to other solutions, GoAccess requires no database, no service installation, and consumes minimal CPU and RAM.

Practical Verification

To verify GoAccess is working correctly, perform the following steps:

  1. Run the real-time log analysis command.
  2. Access several URLs on the Nginx server to generate logs.
  3. Observe metrics such as status codes, response times, and top URLs in the GoAccess interface.
  4. Test access from multiple IPs to verify IP analysis functionality.

Troubleshooting

  • No logs visible: Verify that Nginx is writing logs to /var/log/nginx/access.log. Run tail -f /var/log/nginx/access.log to confirm logs are being written.
  • Log format mismatch: Check the Nginx log format configuration. Use --log-format=COMBINED or adjust the format to match your actual log structure.
  • GoAccess not responding: Ensure the log file is not locked or deleted. Check file permissions and access rights.

References

Assumptions: The user has access to a server running Ubuntu/Debian, Nginx is installed and operational, and access logs are written to /var/log/nginx/access.log. The guide is applicable to both VPS and dedicated server environments, though no specific hardware is assumed.

Related infrastructure & engineering guides: High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478