Splunk Search

How to count "different" log messages

BeaGarcia
New Member

Hello! I want to count how many different kind of errors appeared for different services. 

At the moment, I'm searching for the errors like this 

Index=etc message = "error 1" OR "error 2" OR ... "error N" | chart count by instance_name, message

And I've got as a result:

instance_name | "error 1 for us1" | "error 1 for us2" | ... | "error 1 for usN" | Other

And under those column names, it shows how many times that error appeared. How can I count them without caring about the user and only caring about the "error 1" string?

I mean, I want the result to look like

Instance_name | error 1 | error2 |...| errorN

Labels (6)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Extract the error number from the message and use that instead of message, e.g.

index=etc message="error 1" OR message="error 2" OR message="error N" 
| rex field=message "error (?<error>\d+)"
| chart count by instance_name, error

You will have to change the regex in the rex statement so you extract what you want - the one above just extracts the number after the word "error "

Note if you want the message to be one of A OR B OR C, you use message=A OR message=B OR message=C rather than message=A OR B OR C

You can also use message IN ("A","B","C")

 

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...