Splunk Search

Help with hostname regex

herndona
Engager

I have concocted a basic regular expression to find all Splunk indexes from matching hosts. The idea of the regex is to find all indexes by hosts that:

  1. Begin with "us" or "ln"
  2. The third character (after us or ln) can be any character
  3. The fourth character is an x
  4. The remaining characters can be any character or number
  5. It can also be followed by .intranet.local (but is optional)

\

(Also, sourcetype should be from syslog)

Splunk searches and regexes I have tried are:

(Note, splunk isn't letting me post back slashes in my code... even if I use quadruple backslashes to try and escape, so imagine the forward slashes below are back slashes)

  • sourcetype=syslog host="(?:us|ln)/w*/./w/./w"
  • sourcetype=syslog host_regex="(?:us|ln)/w*/./w/./w"
  • sourcetype=syslog regex host="(?:us|ln)/w*/.w/w*/./w"

If I remove the regex section, and do a search with host="*", I receive indexes with host fields such as:

uslx1099.intranet.local

uslx508.intranet.local

mylx091.intranet.local

usax555

lnax01b

Any assistance or clarification as to what I may be doing wrong would be greatly appreciated.

Thanks,

0 Karma
1 Solution

somesoni2
Revered Legend

Try this

sourcetype=syslog | where match(host,"(?:us|ln)\wx.*") 

View solution in original post

somesoni2
Revered Legend

Try this

sourcetype=syslog | where match(host,"(?:us|ln)\wx.*") 
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...