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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...