8.6. Operating a Centralized Log Server
This section builds the collector sketched in the host table at the top of the chapter: one central host receives the logs of two clients over TLS, files each client's records separately, and survives outages on the clients' disk queues. The host roles again:
| Host | Role |
|---|---|
| collector | Central rsyslog collector; TLS listeners on ports 6514 and 6515 |
| client1 | Forwards all local records to collector port 6514 |
| client2 | Forwards all local records to collector port 6515 |
All three need the rsyslog package (installed by default on Debian) and
rsyslog-gnutls for the TLS driver. Figure 8.4 shows the target.
Figure 8.4. Conceptual view of the collector. Each client holds a disk queue and forwards RFC 5424 over TLS; each listener admits one certificate name and feeds a ruleset that files that host's records under /var/log/remote/.
8.6.1. Designing an Rsyslog Collector and Multi-Host Log Layout
Collecting logs is a design choice before it is a configuration:
| Option | Model | Strengths | Considerations |
|---|---|---|---|
rsyslog imtcp + TLS (this section) |
Syslog records over TCP with client certificates | Scales to many senders; per-host files; mature filtering and queues | Records are syslog-format; files need rotation policy |
systemd-journal-remote |
Native journal export over HTTPS to a directory of journal files | Every journal field survives; reads back with journalctl |
One service per endpoint; journal-file-centric layout |
| No collector | Each host keeps only its own logs | No network, no extra service | Logs lost with the host; no cross-host timeline |
The rsyslog design is used here because it fits the standard tools -
grep, logrotate, and any log shipping downstream. The file layout is
one directory per host:
/var/log/remote/
├── client1/
│ └── all.log
└── client2/
└── all.log
Per-host directories keep one compromised or misconfigured client from
polluting another's records, make retention decisions per host possible,
and let permissions differ if one host's logs are more sensitive. Create
them on collector, as root, owned by root:adm like the system logs:
# install -d -m 750 -o root -g adm /var/log/remote /var/log/remote/client1 /var/log/remote/client2
Silent; 750 lets members of adm read but not write, and everyone else
sees nothing.
8.6.2. Configuring TCP Transport, TLS, and Client Certificate Verification
TLS needs a certificate authority and one certificate per host. The examples use a lab CA; a production deployment can run its own CA the same way or use certificates from an existing one - what matters is that every host trusts the same root and each certificate carries the name its peers will verify. On collector, as root, create a private directory for the material and the CA:
# install -d -m 700 /etc/rsyslog-tls
# openssl req -x509 -newkey rsa:3072 -nodes -keyout /etc/rsyslog-tls/ca.key -out /etc/rsyslog-tls/ca.crt -days 3650 -subj "/CN=Handbook Lab CA"
..+..+.+......+.....+.+..+............+.+.................+.......+.....+. (progress dots omitted)
OpenSSL prints key-generation progress dots to standard error; the capture
is abbreviated and contains no other output. Three openssl subcommands
do all the certificate work in this chapter - req makes keys and
signing material, x509 issues and inspects certificates, and verify
checks chains - with this shared option vocabulary:
| Option | Description |
|---|---|
req -x509 |
Produce a self-signed certificate directly instead of a signing request |
req -newkey rsa:BITS |
Generate a new RSA private key of the given size |
-nodes |
Write the private key without passphrase protection |
-keyout FILE, -out FILE |
Where to write the generated key, and the request or certificate |
-subj /CN=NAME |
Set the subject name without the interactive prompt |
-days N |
Validity period of the certificate, in days |
x509 -req |
Sign a certificate from a signing request |
-CA FILE, -CAkey FILE |
The issuing CA's certificate and its private key |
-CAcreateserial |
Create and keep a serial-number file for issued certificates |
-extfile FILE |
Take certificate extensions from a file |
-noout |
With inspection selectors, print the fields instead of the certificate |
verify -CAfile FILE |
Check a certificate against this trust anchor |
Inspect what was made:
# openssl x509 -in /etc/rsyslog-tls/ca.crt -noout -subject
subject=CN=Handbook Lab CA
Restrict the CA's private key - the whole design's trust rests on it:
# chmod 600 /etc/rsyslog-tls/ca.key
The collector's own certificate needs a name that matches what clients
will connect to, plus a key-usage marking it as a server certificate.
Contents of /etc/rsyslog-tls/collector.ext:
basicConstraints = critical,CA:FALSE
subjectAltName = DNS:collector
extendedKeyUsage = serverAuth
Generate the key and a signing request, sign the request with the CA, and tighten the key:
# openssl req -newkey rsa:2048 -nodes -keyout /etc/rsyslog-tls/collector.key -out /etc/rsyslog-tls/collector.csr -subj "/CN=collector"
.....+......+.........+............+...+ (progress dots omitted)
# openssl x509 -req -in /etc/rsyslog-tls/collector.csr -CA /etc/rsyslog-tls/ca.crt -CAkey /etc/rsyslog-tls/ca.key -CAcreateserial -out /etc/rsyslog-tls/collector.crt -days 365 -extfile /etc/rsyslog-tls/collector.ext
Certificate request self-signature ok
subject=CN=collector
# chmod 600 /etc/rsyslog-tls/collector.key
Verify the chain and the extensions that clients will check:
# openssl verify -CAfile /etc/rsyslog-tls/ca.crt /etc/rsyslog-tls/collector.crt
/etc/rsyslog-tls/collector.crt: OK
# openssl x509 -in /etc/rsyslog-tls/collector.crt -noout -subject -issuer -dates -ext subjectAltName,extendedKeyUsage
subject=CN=collector
issuer=CN=Handbook Lab CA
notBefore=Nov 19 09:03:05 2026 GMT
notAfter=Nov 19 09:03:05 2027 GMT
X509v3 Subject Alternative Name:
DNS:collector
X509v3 Extended Key Usage:
TLS Web Server Authentication
DNS:collector in the Subject Alternative Name is the name TLS
verification actually checks. The certificate exchange itself runs between
the john accounts on all three hosts, through per-purpose subdirectories
of john's workspace. On each of the three hosts, as john, create the
shared layout once:
$ mkdir -p ~/debian-handbook/services-logs/tls/incoming ~/debian-handbook/services-logs/tls/signed ~/debian-handbook/services-logs/tls/public
Silent. Then publish the CA's public certificate so clients can fetch it over their normal accounts - on collector, as root:
# install -m 644 -o john -g john /etc/rsyslog-tls/ca.crt /home/john/debian-handbook/services-logs/tls/public/ca.crt
Silent - the CA certificate is public; only its key is secret. Now the
client certificates. On client1, as john in the workspace, generate
a key and a signing request, and prepare the extension file. Contents of
~/debian-handbook/services-logs/tls/client1.ext:
basicConstraints = critical,CA:FALSE
subjectAltName = DNS:client1
extendedKeyUsage = clientAuth
Note clientAuth: this certificate proves the client's identity to the
collector, the reverse of the server certificate above. Generate the pair:
$ cd ~/debian-handbook/services-logs/tls && openssl req -newkey rsa:2048 -nodes -keyout client1.key -out client1.csr -subj /CN=client1
......+..+..+.....+......+.....+...............+..........+..+...+ (progress dots omitted)
$ chmod 600 client1.key
The key never leaves the client; only the request travels. Send the request and the extension file to the collector's john account:
$ scp -q client1.csr client1.ext john@collector:~/debian-handbook/services-logs/tls/incoming/
scp -q copies silently. The same two steps on client2 with client2 as
the common name produce client2.key and client2.csr. Back on collector,
as root, sign both requests:
# openssl x509 -req -in /home/john/debian-handbook/services-logs/tls/incoming/client1.csr -CA /etc/rsyslog-tls/ca.crt -CAkey /etc/rsyslog-tls/ca.key -CAcreateserial -out /home/john/debian-handbook/services-logs/tls/signed/client1.crt -days 365 -extfile /home/john/debian-handbook/services-logs/tls/incoming/client1.ext
Certificate request self-signature ok
subject=CN=client1
# chown john:john /home/john/debian-handbook/services-logs/tls/signed/client1.crt
# openssl x509 -req -in /home/john/debian-handbook/services-logs/tls/incoming/client2.csr -CA /etc/rsyslog-tls/ca.crt -CAkey /etc/rsyslog-tls/ca.key -CAcreateserial -out /home/john/debian-handbook/services-logs/tls/signed/client2.crt -days 365 -extfile /home/john/debian-handbook/services-logs/tls/incoming/client2.ext
Certificate request self-signature ok
subject=CN=client2
# chown john:john /home/john/debian-handbook/services-logs/tls/signed/client2.crt
Both signing outputs confirmed the subject names; both chown commands
hand the certificates to the account the clients will fetch them from. On
client1, as john, fetch the signed certificate and the CA certificate, and
verify the chain locally before installing anything:
$ cd ~/debian-handbook/services-logs/tls && scp -q john@collector:~/debian-handbook/services-logs/tls/signed/client1.crt . && scp -q john@collector:~/debian-handbook/services-logs/tls/public/ca.crt . && openssl verify -CAfile ca.crt client1.crt
client1.crt: OK
The fetch-and-verify is one sequence: two scp copies followed by a
local chain check. Repeat on client2 for client2.crt. Install the
material into the system path on each client, as root - shown for
client1:
# install -d -m 700 /etc/rsyslog-tls; install -m 644 /home/john/debian-handbook/services-logs/tls/ca.crt /etc/rsyslog-tls/ca.crt; install -m 600 /home/john/debian-handbook/services-logs/tls/client1.key /etc/rsyslog-tls/client1.key; install -m 644 /home/john/debian-handbook/services-logs/tls/client1.crt /etc/rsyslog-tls/client1.crt
One sequence installing four files: the trusted CA, the client key kept at
600, and the client certificate. On client2 the same four commands
install client2.key and client2.crt. Keys and certificates in place,
the collector's side of the transport. Contents of
/etc/rsyslog.d/10-handbook-collector.conf on collector:
global(
defaultNetstreamDriver="gtls"
defaultNetstreamDriverCAFile="/etc/rsyslog-tls/ca.crt"
defaultNetstreamDriverCertFile="/etc/rsyslog-tls/collector.crt"
defaultNetstreamDriverKeyFile="/etc/rsyslog-tls/collector.key"
)
module(
load="imtcp"
StreamDriver.Name="gtls"
StreamDriver.Mode="1"
StreamDriver.AuthMode="x509/name"
)
template(name="CollectedFile" type="string"
string="%timereported:::date-rfc3339%.%timereported:::date-subseconds% %hostname% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n")
ruleset(name="client1") {
action(type="omfile" file="/var/log/remote/client1/all.log"
template="CollectedFile" fileCreateMode="0640" dirCreateMode="0750"
fileOwner="root" fileGroup="adm")
}
ruleset(name="client2") {
action(type="omfile" file="/var/log/remote/client2/all.log"
template="CollectedFile" fileCreateMode="0640" dirCreateMode="0750"
fileOwner="root" fileGroup="adm")
}
input(type="imtcp" port="6514" ruleset="client1" PermittedPeer=["client1"])
input(type="imtcp" port="6515" ruleset="client2" PermittedPeer=["client2"])
Read the pieces. The global block selects the GnuTLS driver and the
collector's own certificate material. The imtcp module gets
StreamDriver.Mode="1" (TLS on) and StreamDriver.AuthMode="x509/name":
peers must present a certificate, and it must be name-authorized.
StreamDriver.Name="gtls" makes every listener on this daemon TLS-only -
there is no accidentally cleartext port. Each input binds one port to one
ruleset and admits exactly one certificate name via PermittedPeer; each
ruleset writes one file with the root:adm 0640 identity created on
demand by fileCreateMode and friends. The CollectedFile template
preserves the original report time with sub-second precision, the
sender's own hostname and tag, and the message. One redundancy is visible
in the collected lines later: %timereported:::date-rfc3339% already
includes microseconds, so the additional %timereported:::date-subseconds%
appends them twice - harmless, but the second property can be dropped in
your own template.
Validate before restarting:
# rsyslogd -N1
rsyslogd: version 8.2504.0, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.
-N1 parses the configuration without starting anything. Restart and
check both listeners:
# systemctl restart rsyslog
# ss -ltnp | grep -E ":6514|:6515"
LISTEN 0 25 0.0.0.0:6514 0.0.0.0:* users:(("rsyslogd",pid=24803,fd=9))
LISTEN 0 25 0.0.0.0:6515 0.0.0.0:* users:(("rsyslogd",pid=24803,fd=7))
LISTEN 0 25 [::]:6514 [::]:* users:(("rsyslogd",pid=24803,fd=10))
LISTEN 0 25 [::]:6515 [::]:* users:(("rsyslogd",pid=24803,fd=8))
The pipeline filters the socket listing (ss -ltnp, from
Chapter 17) down to the two ports; each
listens on IPv4 and IPv6. The client side. Contents of
/etc/rsyslog.d/10-handbook-forward.conf on client1:
global(
defaultNetstreamDriver="gtls"
defaultNetstreamDriverCAFile="/etc/rsyslog-tls/ca.crt"
defaultNetstreamDriverCertFile="/etc/rsyslog-tls/client1.crt"
defaultNetstreamDriverKeyFile="/etc/rsyslog-tls/client1.key"
)
*.* action(type="omfwd"
target="collector" port="6514" protocol="tcp"
template="RSYSLOG_SyslogProtocol23Format"
StreamDriver="gtls" StreamDriverMode="1" StreamDriverAuthMode="x509/name"
StreamDriverPermittedPeers="collector"
queue.type="disk" queue.filename="handbook-client1-fwd"
queue.maxDiskSpace="50m" queue.saveOnShutdown="on"
action.resumeRetryCount="-1" action.resumeInterval="2")
The client verifies the collector's name - StreamDriverAuthMode plus
StreamDriverPermittedPeers="collector" - which is the reverse of the
listener's check, and exactly the pattern Section 8.5.3 previewed. The
queue parameters defer to Section 8.6.4. On client2 the file is identical
except port="6515", the client2 certificate and key, and the queue
filename handbook-client2-fwd. Validate and restart on each client, as
root - shown on client1:
# rsyslogd -N1
rsyslogd: version 8.2504.0, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.
# systemctl restart rsyslog
$ systemctl is-active rsyslog
active
Deliver one record from each client, as john on each:
$ logger -t handbook-tls "message from client1 over TLS"
$ logger -t handbook-tls "message from client2 over TLS"
Both silent. On collector, as root, read each one back from its own file:
# grep -F "message from client1 over TLS" /var/log/remote/client1/all.log | tail -1
2026-11-19T09:04:51.700445+00:00.700445 client1 handbook-tls message from client1 over TLS
# grep -F "message from client2 over TLS" /var/log/remote/client2/all.log | tail -1
2026-11-19T09:04:58.618418+00:00.618418 client2 handbook-tls message from client2 over TLS
Both messages arrived, filed by host, with the sender's own timestamp and tag preserved. The negative test proves the TLS checks are real. On client1, as root, generate a decoy CA and point the forwarder at it:
# openssl req -x509 -newkey rsa:2048 -nodes -keyout /tmp/handbook-bogus.key -out /etc/rsyslog-tls/bogus-ca.crt -days 30 -subj "/CN=Wrong CA"
......+...+....+..+......+.........+ (progress dots omitted)
# sed -i 's#/etc/rsyslog-tls/ca.crt#/etc/rsyslog-tls/bogus-ca.crt#' /etc/rsyslog.d/10-handbook-forward.conf
# systemctl restart rsyslog
The sed swap and restart are both silent. Now the client no longer
trusts the collector's certificate. Send one probe, as john:
$ logger -t handbook-tlsfail "wrong ca probe"
The client refuses the connection, and its own journal says so. As root:
# journalctl -u rsyslog -n 20 --no-pager
Nov 19 09:05:37 client1 systemd[1]: Started rsyslog.service - System Logging Service.
Nov 19 09:05:37 client1 rsyslogd[67038]: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd. [v8.2504.0]
Nov 19 09:05:37 client1 rsyslogd[67038]: [origin software="rsyslogd" swVersion="8.2504.0" x-pid="67038" x-info="https://www.rsyslog.com"] start
Nov 19 09:05:41 client1 rsyslogd[67038]: not permitted to talk to peer 'collector', certificate invalid: signer not found [v8.2504.0]
Selected output; restart lines before the failure and rsyslog's follow-up
detail lines after it were omitted. The decisive line is certificate
invalid: signer not found - the collector's certificate was signed by a
CA the client no longer trusts. Confirm nothing
leaked through anyway, on collector, as root:
# grep -F "wrong ca probe" /var/log/remote/client1/all.log
The command finds nothing and exits 1; no record crossed the unverified channel. Restore the correct CA file, restart the forwarder, and the probe - still queued on the client - is delivered:
# sed -i 's#/etc/rsyslog-tls/bogus-ca.crt#/etc/rsyslog-tls/ca.crt#' /etc/rsyslog.d/10-handbook-forward.conf
# systemctl restart rsyslog
The queue that made the probe survive is the next subsection's subject.
8.6.3. Protecting Listener Access and Separating Logs by Validated Host Identity
Each listener admits one certificate name (Section 8.6.2's
PermittedPeer), and that admission is what makes the per-host file
placement trustworthy. Break it deliberately: on client1, as root, point
the forwarder at client2's port:
# sed -i 's/port="6514"/port="6515"/' /etc/rsyslog.d/10-handbook-forward.conf
# systemctl restart rsyslog
Both silent. The certificate client1 presents is perfectly valid - signed by the trusted CA - but it is the wrong name for that listener. Send a probe, as john:
$ logger -t handbook-identity "client1 wrong listener"
On collector, as root, the rejection is recorded in the collector's own syslog:
# grep -F "peer name not authorized" /var/log/syslog | tail -3
2026-11-19T08:30:01.109199+00:00 collector rsyslogd: error: peer name not authorized - not permitted to talk to it. Names: DNSname: client1; CN: client1; [v8.2504.0 try https://www.rsyslog.com/e/2088 ]
2026-11-19T08:47:51.355687+00:00 collector rsyslogd: error: peer name not authorized - not permitted to talk to it. Names: DNSname: client1; CN: client1; [v8.2504.0 try https://www.rsyslog.com/e/2088 ]
2026-11-19T09:05:16.855185+00:00 collector rsyslogd: error: peer name not authorized - not permitted to talk to it. Names: DNSname: client1; CN: client1; [v8.2504.0 try https://www.rsyslog.com/e/2088 ]
The listener reports both names it saw - the DNS name the client used and
the certificate's common name - and refused both, because port 6515 admits
only client2. The earlier two lines are from previous runs of the same
test. Nothing reached client2's file:
# grep -F "client1 wrong listener" /var/log/remote/client2/all.log
No output, exit 1. Restore client1's port and restart:
# sed -i 's/port="6515"/port="6514"/' /etc/rsyslog.d/10-handbook-forward.conf
# systemctl restart rsyslog
The design point this test pins down: the ruleset - and therefore the
file - is bound to the port, and the port is bound to a validated
certificate name. Separation follows the validated identity, not the
%hostname% field inside the message, which the sender chooses. An
alternative layout accepts all named peers on one port and sorts by that
self-reported hostname; it is less configuration, but it moves the trust
boundary from the collector's TLS check to each forwarder's honesty. The
per-listener design keeps validation and file placement in one place,
which is why it is used here. The resulting layout and permissions, on
collector:
# ls -l /var/log/remote/client1 /var/log/remote/client2
/var/log/remote/client1:
total 12
-rw-r----- 1 root adm 12076 Nov 19 09:05 all.log
/var/log/remote/client2:
total 8
-rw-r----- 1 root adm 5418 Nov 19 09:04 all.log
# stat -c "%U:%G %a %n" /var/log/remote/client1 /var/log/remote/client1/all.log
root:adm 750 /var/log/remote/client1
root:adm 640 /var/log/remote/client1/all.log
Directories 750 root:adm, files 640 root:adm - the same readable-by-
adm convention as the system logs, and created that way by the ruleset's
fileCreateMode and dirCreateMode rather than by after-the-fact
chmod.
8.6.4. Client Disk Queues, Backpressure, and Collector Outages
Stop the collector's rsyslog, as root on collector:
# systemctl stop rsyslog
Stopping 'rsyslog.service', but its triggering units are still active:
syslog.socket
The warning is the socket activation of Section 8.1.1 in action:
syslog.socket is still listening, so the daemon can be - and will be -
restarted on demand; systemctl is pointing out that stopping the service
does not stop the pipeline. The TLS listeners, however, are gone with
the daemon, so the clients now face an outage. On client1, as john, send
three probes:
$ logger -t handbook-queue "outage one"
$ logger -t handbook-queue "outage two"
$ logger -t handbook-queue "outage three"
All three return instantly and silently - the local journal accepted them; delivery is rsyslog's problem now. On client1, as root, see where they wait:
# ls -l /var/spool/rsyslog
total 80
-rw------- 1 root root 77192 Nov 19 09:06 handbook-client1-fwd.00000001
-rw------- 1 root root 590 Nov 19 09:05 handbook-client1-fwd.qi
# du -h /var/spool/rsyslog
84K /var/spool/rsyslog
The forward action's queue materialized on disk: queue.type="disk" made
the queue disk-backed from the start, handbook-client1-fwd.00000001 is
the first data segment, and the .qi file is the queue's metadata. The
segment file is 0600 root because the rsyslog daemon owns the queue.
Bring the collector back, as root on collector:
# systemctl start rsyslog
The client retries on its two-second action.resumeInterval with no
retry limit (action.resumeRetryCount="-1"), and the records appear. On
collector, as root, count them:
# grep -c "outage" /var/log/remote/client1/all.log
6
Six, not three. Each probe was retained twice, because rsyslog's disk queues deliver at least once: after an outage and the replay that follows, the same record can be stored more than once, as Section 8.6.7 examines in detail. The queue itself stays allocated for reuse even when empty - the files remain on disk at their high-water mark:
# du -h /var/spool/rsyslog
108K /var/spool/rsyslog
The remaining parameters bound the arrangement. queue.maxDiskSpace="50m"
caps the disk queue; queue.saveOnShutdown="on" also persists records
that are merely in flight when the client's own rsyslog is stopped or
restarted. The client's journal showed that path working during the
section's repeated restarts: one restart logged queue files exist on
disk, re-starting with 62 messages and replayed them - the identity and
wrong-CA probes queued earlier arrived after the restart rather than
vanishing. Backpressure is therefore two-sided: while the collector is
unreachable, records accumulate up to the cap, and a message that arrives
when the cap is full is discarded - documented rsyslog behavior, and the
reason the cap must be sized to the worst outage you are willing to
buffer.
8.6.5. Retention, Rotation, Capacity, and Permissions on Collected Logs
Collected files need the same lifecycle management as any other log, with
one twist: the files are created by the collector's rsyslog, so the
rotation hook must signal it. Contents of
/etc/logrotate.d/handbook-remote on collector:
/var/log/remote/client1/all.log /var/log/remote/client2/all.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
create 0640 root adm
sharedscripts
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}
Daily rotation, fourteen generations kept, compressed with one cycle of
delay - roughly two weeks of history per host. The postrotate hook calls
/usr/lib/rsyslog/rsyslog-rotate, the helper Debian ships for exactly
this purpose; it tells the running daemon to reopen its output files.
Force a rotation, as root:
# logrotate --force /etc/logrotate.d/handbook-remote
Silent, as ever:
# ls -l /var/log/remote/client1
total 60
-rw-r----- 1 root adm 0 Nov 19 09:06 all.log
-rw-r----- 1 root adm 59096 Nov 19 09:06 all.log.1
The live file was moved aside and a new one created with the configured identity. Force a second time and nothing moves:
# logrotate --force /etc/logrotate.d/handbook-remote
# ls -l /var/log/remote/client1
total 60
-rw-r----- 1 root adm 0 Nov 19 09:06 all.log
-rw-r----- 1 root adm 59096 Nov 19 09:06 all.log.1
Between the two forced runs no new records arrived, so the new all.log
was empty and notifempty skipped it - the same behavior as the
application log in Section 8.5.2, visible here without any noise.
Capacity is the third leg of retention:
# du -sh /var/log/remote
80K /var/log/remote
# df -h /var/log | tail -1
/dev/vda1 98G 1.1G 92G 2% /
du totals the collected trees, and the df line - selected by tail -1
to drop the header - shows the filesystem those trees live on with 92 GB
free. Collectors die by disk exhaustion more often than by anything else;
a check of both numbers belongs in routine monitoring
(Chapter 9 covers capacity tooling). With
fourteen compressed daily generations and a growth rate, the disk need is
a multiplication away.
8.6.6. Searching Collected Events and Preserving Timestamps and Structured Fields
The collected files are plain text, so the standard tools apply - with the caveat that rotated generations are compressed. The timestamp column is where the earlier format decisions pay off:
# grep "message from client1 over TLS" /var/log/remote/client1/all.log | tail -1
2026-11-19T09:04:51.700445+00:00.700445 client1 handbook-tls message from client1 over TLS
The client's own report time - microseconds included - survived the trip;
compare the sender's journal line from Section 8.4.1's format discussion.
(The doubled sub-second digits are the template redundancy noted in
Section 8.6.2.) Field extraction with awk summarizes a stream quickly -
here the first four fields of the last three records: timestamp, host,
process, and the message's first word:
# awk "{print \$1, \$2, \$3, \$4}" /var/log/remote/client1/all.log | tail -3
2026-11-19T09:06:42.170335+00:00.170335 client1 systemd-logind[544] Session
2026-11-19T09:06:42.170441+00:00.170441 client1 systemd[1] session-2743.scope:
2026-11-19T09:06:42.172284+00:00.172284 client1 systemd-logind[544] Removed
Structured data survives because the forwarder used the RFC 5424 template. On client1, as john, send one record with an RFC 5424 structured-data element:
$ logger --rfc5424 --sd-id handbook@32473 --sd-param 'event="rotation"' -t handbook-sd "structured field"
--sd-id names the structured-data element - the @32473 suffix is a
private enterprise number as RFC 5424 requires - and --sd-param adds a
key/value inside it. On collector, as root:
# grep -F "handbook@32473" /var/log/remote/client1/all.log | tail -1
2026-11-19T09:06:42.158132+00:00.158132 client1 1 2026-11-19T09:06:42.157855+00:00 client1 handbook-sd - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="265581"][handbook@32473 event="rotation"] structured field
The full RFC 5424 line arrived intact: the collector's own receive
timestamp first, then the RFC 5424 header with the sender's original
timestamp, and both structured-data elements - rsyslog's own
timeQuality block, which records that the sender's clock was
synchronized (as Chapter 10 arranges), followed
by the application's handbook@32473 element with its event parameter.
Searching compressed generations uses zgrep or zcat | grep exactly as
Section 8.5.2 demonstrated.
8.6.7. Testing Delivery, Recovery, Duplicate Messages, and Delivery Guarantees
A forwarding design is only as good as its failure behavior, and failure behavior only counts if it was tested. This section's walkthrough already broke things deliberately; the checklist, with where each part lives:
- An untrusted collector certificate is refused by the client:
certificate invalid: signer not found, no records delivered (Section 8.6.2). - A valid but wrong-name client certificate is refused by the listener:
peer name not authorized, no records mis-filed (Section 8.6.3). - A collector outage buffers on the client's disk queue and delivers on recovery (Section 8.6.4).
- A client restart replays what was in flight, because
queue.saveOnShutdown="on"persisted it (Section 8.6.4).
One property deserves its own test because it surprises people: at-least- once delivery means duplicates, and duplicates must be expected, counted, and tolerated. Send two identical probes from client1, as john:
$ logger -t handbook-duplicate "duplicate probe"
$ logger -t handbook-duplicate "duplicate probe"
Count the copies on the collector, as root:
# grep -c "duplicate probe" /var/log/remote/client1/all.log
4
Two probes, four stored records. rsyslog's disk-assisted action queues are documented as at-least-once: a record is never silently dropped on an outage or a restart, but the price is that a replay can write a record it had already written - the Section 8.6.4 outage showed the same thing with its count of six for three probes. Consumers of collected logs must therefore treat near-identical lines as possible duplicates, not as events that happened twice; ordering by the preserved original timestamp and matching on content keeps timelines honest. What the design does and does not promise, in one table:
| Aspect | Behaviour in this design | Established by |
|---|---|---|
| Retry policy | Unlimited retries every 2 s (action.resumeRetryCount="-1", action.resumeInterval="2") |
Observed during the outage |
| Buffering | Disk queue on the client, capped at 50 MB (queue.maxDiskSpace) |
Observed growth; the cap was not reached, overflow-discard is documented behaviour |
| After an outage | Queued records are delivered when the collector returns | Observed (counts above) |
| Duplicates | The same record can be stored more than once after a replay | Observed (four stored for two sent, six for three) |
| Loss | If the queue's files are destroyed before delivery, buffered records are lost; a full queue discards new records | Documented behaviour of rsyslog queues |
No syslog forwarding arrangement is exactly-once; if a stream must be, the mechanism has to live in the application or in a transport designed for it, not in the logger.