Filtering and Focusing
Outcome: reports about part of a log — one page, one kind of failure, one address removed, hours instead of days — and a clear statement of the date-range question GoAccess leaves to you.
The honest starting point
GoAccess has no --from and --to
flags. There is no built-in "only last
Tuesday" switch. What it has is better
raw material: it reads a log from
standard input as happily as from a
file, so the whole toolbox of text
filters becomes its filtering language —
you hand it the lines you mean, and it
counts exactly those. The lab verified
each pattern below against its log
(transcript
t08-persistence-and-filtering.txt).
One page, closely
grep 'guide.html' access.log | goaccess - --log-format=COMBINED -o guide.json
The - where the filename goes means
"read standard input". Six lines mention
the guide page (the plain requests, the
query-string visit, the stylesheet-less
direct hits, and the refused POST), and
the report's total is exactly 6 — a
report about one page: who asked, with
what, and what they got.
One kind of failure
awk '$9==404' access.log | goaccess - --log-format=COMBINED -o only404.json
Field 9 of a combined line is the status
code. Three lines survive; the resulting
not-found panel lists /no-such-page
twice and /also-missing.html once, and
nothing else exists in that report's
world. Point the same shape at $9>=500
on a real log and you have a
server-errors-only briefing.
A date range, when you need one, is the
same idea with the date field: combined
logs carry [01/Nov/2026:...] in field
4, so grep '01/Nov/2026' access.log
selects a day, and two greps with a
range tool select a span. It is one step
more manual than a flag would be — and
it works on any field the log contains,
which no pair of flags could.
Excluding an address
Sometimes the noise is a someone: your
own monitoring script, a health-check
probe, your own browser. -e excludes
an address from the panels:
goaccess access.log --log-format=COMBINED -e 127.0.0.1 -o report.json
The lab excluded the only address its log has, to prove the flag bites: every hit landed in the summary's Excl. IP Hits count (27) and the panels emptied. On a real log you would exclude your monitoring address and keep the world. The flag repeats for several addresses, and accepts ranges in the forms the manual lists.
Hours instead of days
The visitors panel defaults to one row
per day. --date-spec=hr asks for hours:
goaccess access.log --log-format=COMBINED --date-spec=hr -o hours.json
The lab's log spans a single hour, so
its panel has one row — 2026110102,
all 27 hits — which proves the grouping
and shows its compact date-hour key. On
a month of logs the same flag turns the
visitors panel into a genuine
hour-by-hour pulse, and --hour-spec=min
goes finer still. (The related
--keep-last=<days> belongs to the
persistence story and is met in
chapter 9.)
What focusing cannot do
Filtering narrows which lines count. It cannot change what a line meant: the fingerprints are still fingerprints, the cached page your server never saw is still absent, and a subset report's "unique visitors" counts fingerprints within the subset — the guide page's 6 lines involve fewer agents than the whole log's 27, and both numbers are honest about different questions. Name the question before you quote the number, in subsets most of all.