Splunk Search

Question on calculating statistics for a field with different values in one event

prettysunshinez
Explorer

I have a difficulty in calculating statistics when different (multiple) values are present for a field in the same event.
My query now extract the error field (for which i have written the regular expression) and looks for the error and calculate count.
How to overcome this..
Please help!

0 Karma
1 Solution

manjunathmeti
SplunkTrust
SplunkTrust

You need to output one comment for each errors so expand error values before running lookup.

Index =  | regular expression to catch error max_match=0 | mvexpand error | lookup lookupfile_name error outputs error_description comments | search comments="$comment$" | stats count by error_description

View solution in original post

0 Karma

woodcock
Esteemed Legend

Try this:

index = ...
| regular expression to catch error max_match=0
| stats count BY error
| lookup lookupfile_name error OUTPUT error_description comments
| search comments="medium"
| stats sum(count) AS count BY error_description
0 Karma

woodcock
Esteemed Legend

This is what it should do; what would you prefer that it do?

0 Karma

manjunathmeti
SplunkTrust
SplunkTrust

You need to output one comment for each errors so expand error values before running lookup.

Index =  | regular expression to catch error max_match=0 | mvexpand error | lookup lookupfile_name error outputs error_description comments | search comments="$comment$" | stats count by error_description
0 Karma

prettysunshinez
Explorer

Thank You @manjunathmeti
It worked 🙂

I also have another question which is a kind of enhancement to the above query..

In the lookup under Comments column I only have 3 catergories (For say : High,Medium,Low)
And now based on the output of the above query (my initial question), if the error5 which is Low and when its count exceeds a certain limit (say 200) ,its Comment has to be changed as Medium.
I'm have no clue as to how to start with it..
Could you kindly help..

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...