Splunk Search

Get count of multiple fields in a single column using STATS or any other

shashank111v
Explorer

HI,

I have events in splunk, where two fields description and msg denotes error messages. When I try to use to below. I tried renaming msg and description to same values but I am not getting an count.

index=work  status=failure
| stats count by description
|appendcols
[search index=work tag=error
| stats count by msg]

I  see below result:

Description   Count          msg

                           10              Account locked

Login failed    20

How can I get below?

Error                  Count

Account Locked 10

Login failed           20

Labels (1)
0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust

Hi

have you tried this https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchReference/ConditionalFunctions#coalesce.28X... before stats?

...
| eval err=coalesce(error,msg)
| stats count by err

r. Ismo 

View solution in original post

isoutamo
SplunkTrust
SplunkTrust

Hi

have you tried this https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchReference/ConditionalFunctions#coalesce.28X... before stats?

...
| eval err=coalesce(error,msg)
| stats count by err

r. Ismo 

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