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!

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!

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