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 Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...