Sub topic 12
Choosing TCP and Queueing Messages
Prerequisites and the delivery problem
This chapter assumes that you can edit rsyslog configuration, restart or reload services with systemctl, and distinguish a client server from a central log server. It also assumes basic knowledge of TCP ports and firewalls.
A log forwarder has two separate problems:
- How to move messages across the network.
- What to do when the receiver is slow or unreachable.
TCP solves part of the first problem. A queue helps with the second.
TCP and UDP
TCP is a connection-oriented transport. It delivers an ordered byte stream and retransmits data that does not reach the peer. This makes TCP a useful default for logs that must arrive in order and with a low chance of network loss.
TCP does not guarantee that the central server permanently stored a message. The receiver might accept the bytes and then fail before writing them to disk. TCP also cannot protect messages that are lost before rsyslog places them in its queue.
UDP sends independent datagrams without creating a connection. It has less protocol overhead, but packets can be lost, duplicated, delayed, or delivered out of order. UDP can be suitable for high-volume telemetry where occasional loss is acceptable. It is usually a poor default for audit or security logs.
| Transport | Strength | Main failure mode | Typical use |
|---|---|---|---|
| UDP | Low overhead and simple delivery | Packets can disappear without notice | Loss-tolerant telemetry |
| TCP | Ordered, retransmitted stream | Connection failure stops immediate delivery | General server logs |
| TCP with a disk queue | Survives receiver outages | Queue storage can fill | Important logs across unreliable links |
The path normally looks like this:
Configure a forwarding queue
An rsyslog action can forward messages over TCP and retain unsent messages in a disk-assisted queue:
# /etc/rsyslog.d/50-forward.conf
action(type="omfwd"
target="loghost.example.com" port="514" protocol="tcp"
queue.type="LinkedList"
queue.filename="fwd_queue"
queue.maxDiskSpace="1g"
queue.saveOnShutdown="on"
action.resumeRetryCount="-1")queue.type="LinkedList" creates an in-memory queue that can grow as messages wait for delivery. queue.filename gives rsyslog a disk spool name. With a disk-assisted queue, messages can remain available when memory is insufficient or rsyslog shuts down cleanly.
queue.maxDiskSpace="1g" limits the disk space used by the queue. action.resumeRetryCount="-1" tells rsyslog to retry indefinitely after a temporary forwarding failure. This prevents a short receiver outage from discarding queued messages.
A queue is not unlimited storage. If the receiver remains offline and the queue reaches its limit, rsyslog must apply its queue overflow behavior. You must choose a limit that fits the client disk and the longest outage you intend to survive.
Choosing a design
Use plain TCP when the receiver is highly available and occasional loss during a short outage is acceptable. Add a disk-assisted queue when the logs are important, network links are intermittent, or the central server can be unavailable for a known period.
TLS can be added to TCP when logs contain sensitive data. Queueing and encryption solve different problems: TLS protects messages in transit, while the queue stores messages until delivery succeeds.
Exercise
Why does TCP alone not guarantee that a log message survives a central-server failure?
Show answer
TCP confirms network delivery to the peer, but it does not confirm that rsyslog wrote the message durably to the central log store.