The Moving Parts
Outcome: you can name each part of a GoAccess run — the log, the format string, the parser, the panels, the outputs, and the optional on-disk storage — and say which part a given problem lives in.
The log (input)
A plain text file, one request per line,
written by the web server — nginx,
Apache, Caddy and their kin all write
one, each in a layout of its own. The
lab's log is nginx's combined layout
and lives in goaccess-lab/access.log:
27 lines, 4,509 bytes. GoAccess never
writes to this file; it only reads.
The format string (the Rosetta stone)
The parser can only read a line if it is
told the line's layout. That telling is
the log format: either a preset name
(COMBINED, COMMON, VHOST, and
friends) or a string of field codes —
%h for the host, %d for the date,
%r for the request, %s for the
status, %b for bytes, %R for the
referrer, %u for the user agent — with
matching date and time formats.
Chapter 5 spells COMBINED out by hand
and proves the spelling against the
preset. A wrong format is the single
most common GoAccess problem, and
chapter 13 is largely about it.
The parser and its counters
The parser walks the file once, line by
line. A line that matches the format
becomes counts in every panel at once:
the page joins the requested-files
ranking, the status joins the status
panel, the agent string is classified
into browser and operating-system
panels, and so on. A line that does not
match is a failed request — counted,
and, if you ask with
--invalid-requests, written to a file
of its own so you can see exactly what
did not parse (chapter 5).
A unique visitor, in GoAccess's counting, is one combination of IP address, date and user agent. Five such combinations appear in the lab's log, although every request came from one machine and a handful of scripts — the first lesson in reading its numbers honestly.
The outputs (three shapes, one truth)
- Terminal dashboard — the panels as a live, navigable screen. The default when no output file is named.
- HTML report — one self-contained file (the lab's was 576,404 bytes) with the data and the charting code inside it. Open it in any browser; send it to a colleague; archive it.
- JSON or CSV — the panels as data, for scripts, spreadsheets and other programs (chapter 7).
Behind all three sits the same counted model, which is why the guide keeps cross-checking one output against another: if the JSON and the dashboard disagree, something is wrong with your run, not with the log.
The storage (optional, on disk)
By default a run is stateless: parse,
report, forget. With --persist,
GoAccess writes its counted model to a
folder of small database files (the
lab's run wrote 151 of them) and a later
run with --restore starts from that
model and adds the next log on top. That
pair is what makes reports survive log
rotation — the server's habit of
closing yesterday's log and starting a
fresh one. Chapter 9 walks the workflow
and its one sharp edge: the database
folder must exist before you name it.
The real-time server (the exception)
One mode breaks the "read a file, write
a report" pattern: --real-time-html
keeps GoAccess running, watches the log
grow, and pushes updates to an open HTML
report over a WebSocket — a live
connection between the program and the
browser. It is the only part of this
guide documented rather than run
(chapter 10), and knowing it exists
completes the map: everything else in
this guide is a snapshot; this is the
river.