To send a CentOS server’s logs to Splunk reliably, configure rsyslog to forward over TCP with an on-disk queue. If the Splunk server goes down, messages are spooled to disk and delivered once it’s back up, so nothing is lost.
rsyslog Forwarding Rule
Add this block to /etc/rsyslog.conf (or a file in /etc/rsyslog.d/). Replace splunk:514 with your Splunk host and listening port:
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
$WorkDirectory /var/lib/rsyslog # where to place spool files
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList # run asynchronously
$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
*.* @@splunk:514
# ### end of the forwarding rule ###
The double @@ means TCP; a single @ would use UDP. Restart rsyslog to apply the change, and make sure Splunk has a matching TCP data input on that port.
Still on the old syslogd? See replacing syslogd with rsyslog and forwarding to Splunk.
