The default rsyslog forwarder uses plain UDP — fire-and-forget, no acks, no encryption. That is fine for a lab; in production, network blips lose minutes of logs and anyone on the path can read them. This article walks through the rsyslog setup we use when logs need to make it to a central collector reliably: RELP for guaranteed delivery, TLS for confidentiality, a disk-assisted in-memory queue so a brief network outage does not drop events, and the templates that keep the structured fields intact.
How to verify
After the config is in place, both sides should agree the link is up and the queue is happy.
# Service status + listening port on the collector
sudo systemctl status rsyslog --no-pager
ss -lntp | grep -E ':(514|6514|2514)\b'
# rsyslog's own metrics — queue size, error counters
sudo rsyslogd -N1 # config syntax check
sudo grep -i 'error\|fail' /var/log/syslog | tail -20
echo '<134>test from $(hostname) at $(date)' | logger -t test-forward
# On the collector:
sudo journalctl -u rsyslog --since "5 min ago" | grep test-forward
sudo tail -n5 /var/log/remote/<your-host>/syslog
# Queue depth on the shipper
sudo ls -la /var/spool/rsyslog/
If /var/spool/rsyslog/ is empty and logs are being received on the collector, the link is healthy. If files there are growing without bound, the collector is unreachable or rejecting connections — diagnose by tailing the shipper’s internal.log (configured via module(load="impstats")).
What’s happening
rsyslog has three layers worth understanding. Modules (im* input, om* output) define where logs come from and where they go. Rulesets filter and route. Queues sit between an input and an output and decide what to do when the output is slow.
The shipping protocol matters. Plain UDP is the original syslog — no acks, no retransmission, no encryption. TCP adds delivery acks at the transport layer but no application-level ack. RELP (Reliable Event Logging Protocol) adds an application-level ack — the receiver confirms each batch and the sender retries on failure. For audit-grade or compliance-bound forwarding, RELP over TLS is the only sane choice.
The queue choice matters as much as the protocol. The default in-memory queue holds events in RAM and drops them on a restart. A disk-assisted queue (queue.type="LinkedList", queue.fileName=...) keeps the in-memory queue for speed and spills to disk when it grows past queue.highWatermark. A network outage then means the queue grows on disk and replays on reconnect; no logs lost.
The procedure
-
On the collector (the host receiving logs), enable RELP-over-TLS input.
sudo apt install -y rsyslog rsyslog-relp rsyslog-gnutls# /etc/rsyslog.d/10-relp-server.conf module(load="imrelp") module(load="omfile") # TLS server credentials global(defaultNetstreamDriver="gtls" defaultNetstreamDriverCAFile="/etc/rsyslog.d/ca.crt" defaultNetstreamDriverCertFile="/etc/rsyslog.d/server.crt" defaultNetstreamDriverKeyFile="/etc/rsyslog.d/server.key") input(type="imrelp" port="2514" tls="on" tls.authMode="x509/name" tls.permittedPeer=["*.internal.example.com"]) # Route remote logs to per-host directories template(name="RemoteHostFile" type="string" string="/var/log/remote/%FROMHOST%/%PROGRAMNAME%.log") template(name="RemoteHostFormat" type="string" string="%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n") ruleset(name="remote") { action(type="omfile" dynaFile="RemoteHostFile" template="RemoteHostFormat" fileCreateMode="0640" dirCreateMode="0750" fileOwner="syslog" fileGroup="adm") } input(type="imrelp" port="2514" ruleset="remote")tls.permittedPeeris what stops anyone on the network from impersonating a shipper if they manage to get a cert from a different CA path. -
Open the firewall and reload.
sudo ufw allow from 10.0.0.0/16 to any port 2514 proto tcp sudo rsyslogd -N1 sudo systemctl restart rsyslog -
On the shipping host, configure the forwarder with a disk-assisted queue.
sudo apt install -y rsyslog-relp rsyslog-gnutls sudo mkdir -p /var/spool/rsyslog sudo chown syslog:syslog /var/spool/rsyslog# /etc/rsyslog.d/90-forward.conf module(load="omrelp") global(defaultNetstreamDriver="gtls" defaultNetstreamDriverCAFile="/etc/rsyslog.d/ca.crt" defaultNetstreamDriverCertFile="/etc/rsyslog.d/client.crt" defaultNetstreamDriverKeyFile="/etc/rsyslog.d/client.key") action(type="omrelp" target="syslog-collector.internal" port="2514" tls="on" tls.authMode="x509/name" tls.permittedPeer=["syslog-collector.internal.example.com"] template="RSYSLOG_SyslogProtocol23Format" queue.type="LinkedList" queue.fileName="fwd_relp" queue.spoolDirectory="/var/spool/rsyslog" queue.maxDiskSpace="2g" queue.highWatermark="200000" queue.lowWatermark="100000" queue.discardMark="1000000" queue.size="500000" queue.saveOnShutdown="on" action.resumeRetryCount="-1" action.resumeInterval="30")action.resumeRetryCount="-1"means “retry forever” — paired with the disk-assisted queue, this is what survives a multi-hour collector outage. -
Test end-to-end with a one-shot.
logger -t prod-test "rsyslog RELP+TLS test from $(hostname)" # On the collector, after a second or two: sudo tail -n5 /var/log/remote/$(hostname -s)/prod-test.log -
Enable internal stats so you can monitor the queue. Without this you find out about a backlog only after disk fills.
# /etc/rsyslog.d/05-impstats.conf module(load="impstats" interval="60" severity="6" log.file="/var/log/rsyslog-stats.log" log.syslog="off" format="cee")Then scrape
/var/log/rsyslog-stats.logwith Promtail/Filebeat and alert on queue size, discarded events, and failed-to-deliver counters. -
Add log rotation on the collector. The per-host files in
/var/log/remote/grow without bound otherwise.# /etc/logrotate.d/rsyslog-remote /var/log/remote/*/*.log { weekly rotate 12 compress delaycompress missingok notifempty postrotate /usr/lib/rsyslog/rsyslog-rotate endscript }
Operational notes
- A
permittedPeervalue that does not match the certificate’s CN means the connection is silently rejected with no log on either side — verify withopenssl s_client -connect host:2514 -showcerts. - Disk-assisted queues do not save in-flight events on
kill -9or a node power-off; onlysaveOnShutdown="on"covers a clean restart. - A
queue.maxDiskSpacetoo small means a network outage of more than a few hours hits the cap and starts discarding; size it for your worst plausible outage plus headroom. - The collector’s filesystem fills quickly under unexpected log spikes — set up
dfalerts on/var/log/remote/as a separate alert from the host’s/. - Plain TCP forwarding (“@@host:514”) looks like RELP from the outside but has no application-level ack and silently loses events when the receiver restarts.
For the journald-side equivalent of structured forwarding, see journalctl-filtering-deep. For shipping the same logs into Loki instead, see promtail-log-shipping.
Stack Harbor runs rsyslog forwarders this way on the managed operations tier — RELP+TLS, disk-assisted queues, certs rotated on the same schedule as the rest of the PKI, and the queue depth on every shipper graphed and alerted on.