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!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...