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!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

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

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...