Sub topic 16
Troubleshooting
This chapter assumes you have built the pipeline from the earlier chapters. That means journald and rsyslog on each client, a TCP receiver writing per-host files, logrotate on both sides, and optionally TLS. You should be comfortable with systemctl, journalctl, ss, and reading firewall rules.
A method: follow the message
A log line passes through several stages. A failure at one stage looks like silence at the next. Test the stages in order and stop at the first one that fails. Don't start by editing configuration files.
Stage 1: the message never leaves the client
Send a tagged test message and check that it exists locally before you blame the network.
logger -t demo "probe $(date +%s)"
journalctl -t demo -n 3 --no-pager
sudo rsyslogd -N1
systemctl status rsyslog --no-pagerIf the message is missing from the journal, the problem is local. If rsyslogd -N1 reports an error, rsyslog may still be running on its old configuration, or it may have failed to start. Read the line number in the error. The usual causes are an unbalanced parenthesis in an action() block or a module used before its module(load=...) line.
Next, look at the client's queue. With queue.filename="fwd_queue", a growing set of files in /var/spool/rsyslog means messages are being accepted but not delivered. Check this before assuming messages are lost.
ls -lh /var/spool/rsyslog/
journalctl -u rsyslog --since "10 min ago" --no-pager | tail -20Lines such as connection refused or action ... suspended show that the client can't reach the receiver. With action.resumeRetryCount="-1" it keeps retrying until it can, so these lines don't mean data has been dropped.
Stage 2: the network path
Test the path from the client, then watch the receiver.
# On the client
nc -vz loghost.example.com 514
# On the receiver
sudo ss -tlnp | grep ':514'
sudo tcpdump -ni any tcp port 514 -c 10Each result points to a different cause:
- Connection refused: rsyslog isn't listening, or the
imtcpmodule orinput()line is missing. - Timeout: a firewall is dropping the packets. Check
firewall-cmd --list-all,ufw status, or cloud security groups. - tcpdump shows packets but no file appears: the problem is in the receiver's rules or in file permissions.
Stage 3: the receiver accepts but does not write
If the listener works and packets arrive, check how the receiver handles them.
- Run
sudo rsyslogd -N1on the receiver. - Check that the ruleset is bound to the input:
input(type="imtcp" port="514" ruleset="remote"). Withoutruleset=, messages go to the default ruleset and are filed under/var/log/messagesor/var/log/syslog, not in/var/log/remote. - Check that the directory exists and that the rsyslog user can write to it. rsyslog creates the per-host subdirectories, but it needs write access to
/var/log/remote. - On SELinux hosts, look for denials:
sudo ausearch -m avc -ts recent. On AppArmor hosts, checkjournalctl -k | grep DENIED. A non-standard directory often needs the right label, for examplesemanage fcontextfollowed byrestorecon -Rv. - Check free space and inodes with
df -h /var/loganddf -i /var/log. A full disk looks like a hung receiver.
Wrong file names usually come from %HOSTNAME%. That property is the hostname inside the message, which a misconfigured client can get wrong. Messages from a host that calls itself localhost all land in one directory. Fix the client's hostname, or use %fromhost% in the template to name the file by the sending host's resolved name.
Stage 4: TLS failures
TLS errors appear in the rsyslog journal on both sides. Read both, because one side usually reports a clearer message.
journalctl -u rsyslog --since "10 min ago" --no-pager | grep -iE 'tls|gtls|certificate|handshake'
openssl s_client -connect loghost.example.com:514 -CAfile /etc/pki/rsyslog/ca.pem </dev/null 2>&1 | grep -E 'Verify return|subject|issuer|notAfter|verify error'| Symptom | Likely cause |
|---|---|
| `peer name not authorized` | The `StreamDriverPermittedPeers` value doesn't match the certificate's name (CN or SAN). |
| `certificate verify failed` | The CA file is wrong or incomplete, or the receiver sent no intermediate certificate. |
| `certificate is not yet valid` | The client's clock is behind. Fix time sync first. |
| `certificate has expired` | Check `notAfter` and renew. |
| Handshake fails right after a client starts sending plain text | One side has `StreamDriver.Mode="1"` and the other doesn't. |
Both sides must use the TLS mode. If only the receiver uses it, plain-text clients are rejected or produce garbage.
Stage 5: rotation problems
Always run a dry run before editing a rotation file.
sudo logrotate -d /etc/logrotate.d/remote
sudo logrotate -f /etc/logrotate.d/remote
systemctl list-timers logrotate.timer
sudo cat /var/lib/logrotate/status 2>/dev/null || sudo cat /var/lib/logrotate/logrotate.statusDebug mode (-d) makes no changes. It reports what logrotate would do and why it skips a file. The state file lists the last rotation time of each log. If a log was never rotated, it has no entry.
Common causes:
- Nothing rotates: the timer is inactive (on older systems, check cron), the glob doesn't match any files, or
notifemptyis skipping empty files. skipping because parent directory has insecure permissions: the directory is writable by a group or user that logrotate doesn't trust. Addsu user groupto the stanza, or fix the permissions.- The log is rotated but the old file keeps growing: the service still holds the old file open because it never saw a HUP. Check with
sudo lsof +L1 | grep -i logand verify that thepostrotatecommand succeeds. - A postrotate error stops the stanza: run the command by hand. With
sharedscripts, it runs once for the whole pattern. - Disk fills despite rotation:
rotate 30with daily rotation keeps 30 files. Multiply by the daily volume, and check whether one chatty host dominates.
Putting it together: a symptom table
| Symptom | First check |
|---|---|
| Test message is missing on the server | `ls /var/spool/rsyslog` on the client, then `nc -vz` |
| Messages are in `/var/log/messages` on the server | The `ruleset=` binding on `imtcp` |
| All messages from several hosts go to one directory | Hostname set on the clients |
| Timestamps are hours off | Time sync (`timedatectl`) and time zones |
| Receiver CPU or disk is saturated | Message rate per host, and queue settings |
Exercise
A client's test message never appears on the central server. nc -vz loghost.example.com 514 succeeds, rsyslogd -N1 on the receiver reports no errors, and tcpdump on the receiver shows packets arriving. Name two likely causes and the command that tests each.
Show answer
The messages may be going to the wrong ruleset because input(type="imtcp" ...) has no ruleset="remote". In that case they appear in /var/log/messages or /var/log/syslog, and you can confirm it with sudo grep demo /var/log/messages. The receiver may also be unable to write to /var/log/remote, because of permissions, a full disk, or an SELinux or AppArmor denial. Test with ls -ld /var/log/remote, df -h /var/log, and sudo ausearch -m avc -ts recent.