Splunk Search

count of the exact match

prettysunshinez
Explorer

Hi,

I would want to have the count of a string (say "abcdef").
sometimes the string occurs multiple times in the same event.
But stats count by host is giving me the count of events where the string is present and not the count of string present inside an event also

Kindly help!

Thanks...

Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@prettysunshinez

You can use rex command to get list of matching values in myVal field.

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/rex

Please try this.

index=YourIndex  | rex max_match=0 field=_raw "(?<myVal>abcdef)" | eval count=mvcount(myVal)

Sample:

| makeresults | eval _raw="abcdef xgz mjjhj zkzkk abcdef" | rex max_match=0 field=_raw "(?<myVal>abcdef)" | eval count=mvcount(myVal)

Here abcdef is sample string.

Thanks

0 Karma
Get Updates on the Splunk Community!

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

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 ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...