Splunk Search

hostname regex path help

tiernan
New Member

I have files in a directory like this:
/home/user/files/servername_01020304050607.log
How can I get the servername only?

Tags (3)
0 Karma

dwaddle
SplunkTrust
SplunkTrust

This is a good job for host_regex, which is an option in inputs.conf. A host_regex similar to this should work for newly indexed data. (It won't fix previously indexed data is my point)

[monitor:///home/user/files]
host_regex=^/home/user/files/([^_]+)_\d+\.log$

sbrant_tt
Explorer

This should do it:

^/\w+/\w+/\w+/(?<server>\w+)_
0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...