Sub topic 3
Time sync and host identity
This chapter assumes you can edit files with sudo, restart systemd services, and open TCP ports in a firewall. You should also know what a hostname is and what /var/log contains.
A central log server can only order and attribute messages if every sender has an accurate clock and a unique name.
Time sync
Check whether the clock is synchronized:
timedatectl statusLook for System clock synchronized: yes. If it says no, install and enable chrony, an NTP (Network Time Protocol) client, on every server.
Host identity
rsyslog writes each sender's hostname into its messages, and the receiver uses that name to build file paths. Give each server a unique, fully qualified name:
sudo hostnamectl set-hostname web01.example.comChoosing TCP and queueing messages
UDP sends messages without confirming delivery. TCP confirms delivery, so use it for forwarding. A disk-assisted queue holds messages while the central server is unreachable:
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")Rotating and sizing the central store
The receiver writes one directory per host. Rotate those files daily on the central server:
/var/log/remote/*/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
sharedscripts
postrotate
/usr/bin/systemctl kill -s HUP rsyslog.service
endscript
}To size the disk, multiply the average daily log volume by the number of retained days, then add headroom for bursts.
Encrypting log traffic with TLS
Add TLS to the client action with the gtls driver. The client checks that the server's certificate matches its name:
action(type="omfwd" target="loghost.example.com" port="514" protocol="tcp"
StreamDriver="gtls"
StreamDriverMode="1"
StreamDriverAuthMode="x509/name"
StreamDriverPermittedPeers="loghost.example.com")The client and server also need the global certificate settings, which use a certificate authority file shared by both sides.
Testing forwarding and rotation
Validate the rsyslog syntax, send a test message, and check it on the central server:
sudo rsyslogd -N1
logger -t demo "test message from $(hostname)"
sudo tail /var/log/remote/*/demo.logDry-run and then force a rotation:
sudo logrotate -d /etc/logrotate.d/remote
sudo logrotate -f /etc/logrotate.d/remoteTroubleshooting
| Symptom | Check | Column |
|---|---|---|
| Messages missing on the server | `sudo ss -tlnp \ | grep 514` and firewall rules |
| Clients report errors | `sudo journalctl -u rsyslog -n 50` | |
| Wrong or duplicate host names | `hostnamectl status` on the sender | |
| Timestamps out of order | `timedatectl status` on every server |
Where to go next
rsyslog handles transport and files well. Log shippers such as Fluent Bit or Vector, paired with a search backend such as OpenSearch or Loki, add indexing and search across many hosts.
Exercise
A client's messages arrive at the central server with timestamps an hour off. Which command do you run on the client first, and what should you expect to see?
Show answer
Run timedatectl status on the client. Expect System clock synchronized: yes and the correct time zone. If the clock is not synchronized, fix NTP (for example, with chrony) before you check the rsyslog configuration.