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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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