Getting Data In

Host based on filename

ehastings82
New Member

How can you create a "host" by the file name being indexed? Im looking to index my firewall configuration files, and currently the snapshots are saved with the firewalls hostname. Clear as mud?

0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

You can look at the host_segment and host_regex settings that can be used with the file monitor stanzas in inputs.conf, to extract the source host from the file path.

View solution in original post

rturk
Builder

FYI, and as a supplemental to the above answer, I keep my files in the following directory:

/var/splunk/input/mms_logs/

The filename structure is:

mms_HOST-IP-ADDRESS_TIMESTAMP.log

examples:

mms_10.152.58.100_20110101_004000_06137.log
mms_10.152.58.194_20110121_120000_70656.log

Now to extract the IP address portion of filename as a host, I used the following regex:

/var/splunk/input/mms_logs/mms_(\d+.\d+.\d+.\d+)_\d+

Voila! From the above examples I know have two hosts (10.152.58.100 & 10.152.58.194), along with all of the events that are hosted within the files 🙂

Hope this helps someone!

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

You can look at the host_segment and host_regex settings that can be used with the file monitor stanzas in inputs.conf, to extract the source host from the file path.

ehastings82
New Member

Your the man!!!

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...