GoAccess is the right tool for fast, ad-hoc analysis of Apache access logs — it runs as a terminal UI, an HTML report, or a realtime dashboard, parses the standard log formats out of the box, and finishes a 24-hour log in seconds. This article covers the install, the right log format declaration, the realtime mode that we keep on screen during incidents, and the patterns we look for during a daily read.
How to verify
Confirm GoAccess is installed and pointed at a parseable log file:
which goaccess && goaccess --version
head -1 /var/log/apache2/access.log
ls -la /var/log/apache2/access.log /var/log/apache2/example.com-access.log 2>/dev/null
sudo goaccess /var/log/apache2/access.log --log-format=COMBINED -o /tmp/report.html --no-global-config
The first 10 lines of the access log tell you the format. The Ubuntu default CustomLog ... combined produces lines that GoAccess parses with --log-format=COMBINED. Custom formats need an explicit format string.
What’s happening
GoAccess reads a log file (or stdin), parses each line into fields (timestamp, IP, request, status, bytes, referrer, user agent), and aggregates them into reports — top URLs, top IPs, top user agents, HTTP status code distribution, time-of-day traffic curve, geographic distribution (with a GeoIP database).
Three output modes:
- Terminal UI (default) — interactive ncurses interface. Best for live exploration.
- HTML report (
-o report.html) — static HTML file. Best for sharing with stakeholders. - Realtime HTML (
-o report.html --real-time-html) — HTML file plus an embedded WebSocket pushing live updates. Best for a wall display during an incident.
For Apache, the format declaration matters. The “combined” format is:
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
That maps to GoAccess --log-format=COMBINED --date-format=%d/%b/%Y --time-format=%H:%M:%S. The shortcut --log-format=COMBINED sets all three.
The procedure
-
Install GoAccess. Available in Ubuntu and Debian archives; for the latest features, use the upstream repository:
sudo apt install -y goaccess # or for upstream echo "deb https://deb.goaccess.io/ $(lsb_release -cs) main" \ | sudo tee /etc/apt/sources.list.d/goaccess.list wget -qO - https://deb.goaccess.io/gnugpg.key | sudo gpg --dearmor -o /usr/share/keyrings/goaccess.gpg sudo apt update && sudo apt install -y goaccess -
Run the terminal UI against a log file.
sudo goaccess /var/log/apache2/access.log --log-format=COMBINEDUse number keys 1-9 to jump between modules; arrow keys to scroll;
sto sort within a module;qto quit. -
Generate an HTML report. For a one-off report you can email or pin to the wiki:
sudo goaccess /var/log/apache2/access.log \ --log-format=COMBINED \ -o /var/www/internal/reports/apache-$(date +%Y%m%d).html -
Run in realtime mode. During incident response, point a browser at the report URL and leave it open:
sudo goaccess /var/log/apache2/access.log \ --log-format=COMBINED \ -o /var/www/internal/reports/live.html \ --real-time-html \ --port=7890 \ --ws-url=wss://reports.example.com:7890The HTML page opens a WebSocket to the GoAccess process and updates the dashboard every few seconds as new log lines land.
-
Aggregate across multiple log files. When Apache writes per-vhost logs, point GoAccess at the lot:
sudo goaccess /var/log/apache2/*access.log* --log-format=COMBINED -o /tmp/all-sites.htmlGoAccess handles gzipped logs (logrotate’s
compressoutput) transparently. -
Persist state across log rotations. By default each run starts fresh. To accumulate across days:
sudo goaccess /var/log/apache2/access.log \ --log-format=COMBINED \ --persist --restore \ --db-path=/var/lib/goaccess \ -o /var/www/internal/reports/rolling.htmlThe state file at
/var/lib/goaccess/persists between runs; subsequent runs pick up where the previous left off. -
Wire a daily cron. A common pattern: rotate the live log overnight, run GoAccess on the previous day’s file, write a timestamped HTML report:
# /etc/cron.d/apache-daily-report 5 0 * * * root /usr/bin/goaccess /var/log/apache2/access.log.1 \ --log-format=COMBINED \ -o /var/www/internal/reports/apache-$(date +\%Y\%m\%d).html
Common pitfalls
- A custom
LogFormatin Apache breaks theCOMBINEDshortcut — declare the format explicitly with--log-format='%h ... 'matching your Apache string. - Per-vhost logs are easier to read in GoAccess (one report per site) than a single shared log; per-vhost logs are also faster to slice during incidents.
- The
--real-time-htmlWebSocket needs port 7890 (default) reachable from the browser; behind a CDN or LB, proxy the WebSocket explicitly or change the port. - GoAccess strips query strings by default — for sites where the path is mostly query-driven (search pages, API endpoints), add
--all-static-filesand--no-query-stringadjustments to match what you want. - Realtime mode does not lock the log file but does keep reading from where it left off; restarting GoAccess loses the in-memory state unless
--persistis enabled.
Stack Harbor leaves a GoAccess realtime dashboard running on the operations wall for Apache fleets under active incident — it is the fastest way to see traffic shape change in real time without waiting for a dashboard to refresh. The daily report cron is part of the Managed Operations baseline; it surfaces patterns (slow growth in 5xx, a new top URL, a sudden spike from one ASN) before they become tickets.