Splunk "host" Field Enhancement For Syslog-ng

We are very fortunate where I work to have Splunk. It’s an incredibly powerful indexing tool that can “eat all your IT data” and report on it in many different ways. We mostly use it to do simple searches for troubleshooting, but we’re always building more expertise as time permits.
Splunk is set up to index syslog messages very nicely by default. It takes each syslog message and intelligently recognizes the date/time stamp, then “extracts” all the fields and names them things like “host”, “eventtype”, “event_desc”, “error_code”, “log_level”, and so on.  This post focuses on the “host” field, which is the IP address of the end device (router, switch, firewall, etc).
In our environment, we send all our syslogs to a Linux server running a free open-source tool called syslog-ng. With it, we do two things: (1) save a copy of each syslog message on the local server in a flat text file named for the source IP address where it came from, and (2) forward a copy to our Splunk indexing server using TCP port 9998.
For a while I’ve noticed that our Splunk lists all syslog messages with a “host” field that is the IP of the syslog-ng server. I was able to do some research this morning and “fixed” this so now all the syslog-ng forwarded messages have their host field set to the source IP address of their original sending device (router/switch/firewall).
Here’s how I did it:
1. Created props.conf file in /san/splunk/etc/system/local with the following contents
[source::tcp:9998]
TRANSFORMS = syslog-header-stripper-ts-host syslog-host
2. Then restarted splunk with this command:
service splunk restart
Information sources I used:
Happy Splunking!
Advertisements

One thought on “Splunk "host" Field Enhancement For Syslog-ng

  1. Hi Patrick,

    A better solution is to put a lightweight forwarder on your syslog host and have Splunk set host based on the segment on the syslog-ng path in which you are monitoring before forwarding. A Splunk forwarder can support queuing and load balancing, so it's superior to a TCP input.

    In this way, you can get the actual host name (In your case you'd have to change how syslog-ng is writing the file). If you have everything in DNS, it works great.

    And there's no transform required. I for one would be perturbed if a bunch of my Splunk hosts were IP addresses.

    Hope this helps.

    -Frank

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s