Splunk Search

Splunk wildcard for specific position of character in a host list

utk123
Path Finder

I have a table with more than 50000 hostnames. I want to run a wild card for 5th & 6th character in a hostname list.

My list sample:

hostname
SERVINBBB01
SERRCNAAA01
SERSSPBBC55
SERRINAAC98
SERWINSSS11

 

In my search result, I want to get list of hosts with IN in 5th & 6th location.

Results should be:

hostname
SERVINBBB01
SERRINAAC98
SERWINSSS11

 

With asterisk(*) (example: *IN*) I am not able to get these results, as characters before and after 5th, 6th position are not same always.

Labels (1)
Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@utk123 

Can you please try this?

YOUR_SEARCH 
| regex hostname="(?<=^.{4})IN"

 

My Sample Search :

| makeresults | eval _raw="hostname
SERVINBBB01
SERRCNAAA01
SERSSPBBC55
SERRINAAC98
SERWINSSS11
"| multikv forceheader=1
| table hostname | regex hostname="(?<=^.{4})IN"


 Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

View solution in original post

utk123
Path Finder

Thanks KV, that works perfect.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@utk123 

Can you please try this?

YOUR_SEARCH 
| regex hostname="(?<=^.{4})IN"

 

My Sample Search :

| makeresults | eval _raw="hostname
SERVINBBB01
SERRCNAAA01
SERSSPBBC55
SERRINAAC98
SERWINSSS11
"| multikv forceheader=1
| table hostname | regex hostname="(?<=^.{4})IN"


 Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...