Splunk Search

Find data in indexes with only two leters in the title

hartfoml
Motivator

I have lots of indexes All of the Organizations have there data in indexes with only two letters like index=os

I want to do a search like this [ *| stats distinct_count(host) by index ] to find all the hosts for each org but I only want the indexes with two letters.

I tried this [ * | regex org="index=(?\w\w)\s" | stats distinct_count(host) by org ] but it did not work

Can anyone help

Tags (2)
0 Karma
1 Solution

lukejadamec
Super Champion

Try using rex instead:

index=* |rex field=index "^(?P<org>\w\w)$" | stats distinct_count(host) by org 

It should grab only indexes with 2 letter names, and create a field called org.

View solution in original post

lukejadamec
Super Champion

Try using rex instead:

index=* |rex field=index "^(?P<org>\w\w)$" | stats distinct_count(host) by org 

It should grab only indexes with 2 letter names, and create a field called org.

hartfoml
Motivator

Thanks this worked

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...