Splunk Search

Total counts of one field based on distinct counts of another field

jawebb
Explorer

This seems like it should be simple, but I'm new to Splunk and can't figure it out. I have one field dc(Name) that corresponds with another field that has multiple values.

For example:

Name: Values:
PC1 Value1, Value2, Value3
PC2 Value1, Value2, Value4
PC3 Value1, Value2

I need to get a count of the total number of distinct "Values" for distinct "Names". So, the sum of 3 values for PC1, 3 for PC2, 2 for PC3 etc...Keep i mind this comes from a daily DB input so the events will duplicate after every import. I looked into a few different commands but they don't seem to be working for this task.

Thanks for any help.

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

... | stats values(Values) AS Values by Name | eval numValues=mvcount(Values)

View solution in original post

woodcock
Esteemed Legend

Like this:

... | stats values(Values) AS Values by Name | eval numValues=mvcount(Values)

jawebb
Explorer

Thanks! That seemed to do the trick.

0 Karma

somesoni2
Revered Legend

Do not forget to close the question by accepting the answer.

0 Karma

somesoni2
Revered Legend

Is the field Values a multivalued field OR it's a single string with multiple values separated by comma? What is your current search?

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