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!

Splunk Search APIを使えば調査過程が残せます

   このゲストブログは、JCOM株式会社の情報セキュリティ本部・専任部長である渡辺慎太郎氏によって執筆されました。 Note: This article is published in both Japanese ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...