Splunk Search

Obtain a count of hits in a query of regexes

kimberlytrayson
Path Finder

I am searching for a list of regexes in a splunk alert like this:

... | regex "regex1|regex2|...regexn"

Can I modify this query to get a table of the regexes found along with their count. The table shouldn't show rows with 0 counts.

regex2 17
regexn 3
0 Karma
1 Solution

to4kawa
Ultra Champion
 ... | regex "regex1|regex2|...regexn"
| rex  max_match=0 "(?<countfields>regex1|regex2|...regexn)"
| stats count by countfields

View solution in original post

to4kawa
Ultra Champion
 ... | regex "regex1|regex2|...regexn"
| rex  max_match=0 "(?<countfields>regex1|regex2|...regexn)"
| stats count by countfields

kimberlytrayson
Path Finder

Great answer @to4kawa.

Looks like | regex line is not needed. This is working for me. Notice the extra brackets.

| rex max_match=0 "(?P<countfields>((regex1)|(regex2)|..|(regexn)))"
| stats count by countfields
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

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