Splunk Search

How to generate a stats count search on field with interchanging values?

mpatel11
Explorer

hi,

looking to do a stats count something like below.

Field1:
A,B
A
B,A
B,A,C
A,C

each row accounts for different events. now need a count on all A's, B's and C's.
so the result be something like:

Value |Count
A | 5
B | 3
C | 2

Tags (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

This should get you started.

... | mvexpand Field1 | stats count by Field1
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

This should get you started.

... | mvexpand Field1 | stats count by Field1
---
If this reply helps you, Karma would be appreciated.

mpatel11
Explorer

wow. it worked perfect. at first didn't work. then figured out I needed to convert my field to mv before applying any mv functions on it.

final query : ....| makemv delim="," Field1| mvexpand Field1| stats count by Field1

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...