Splunk Search

how to group similar messages into one message and get count of them

REACHGPRAVEEN
Explorer

Example:  errormessages    total

                    user a not found.     7

                    user b not found.      5

                    user c not found.      10

Result should be : 

                    user not found.      22

Labels (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @REACHGPRAVEEN,

Please try below;

| eval errormsg=if(errormessages LIKE "user % not found","user not found","")
| stats sum(total) as total by errormsg
If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @REACHGPRAVEEN,

I used your sample data. Using a similar method that I sampled, you should be able to convert to a unique value to make a sum. If there is another field in your logs like error_id you can use that field for grouping.

It is not easy without knowing your data. 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

REACHGPRAVEEN
Explorer

Thanks for the response. but i do have lot of messages with that criteria. in that case do we have to write for  each message like above

0 Karma

REACHGPRAVEEN
Explorer

i have messages as below:

1) Exception message: {"errorMessage":"Unable to find element with pathh '//input[@type=text][@name='User']'",.........

2) error, please visit: www.testsel.com .  xxxxxx

3) error=the user xxxx already exists (more number of users are there)

4) error= we were unable to process you request {xx=cvb,xx=asdf,}

5) Exception message:  no such user:  Unable to locate user: {xx=cvb,xx=asdf,}}

 

the result should be:

errormessage                                                       total

Unable to find element with path.                total count of similar messages beside

please visit: www.testsel.com                     total count of similar messages beside

the user already exists                                     total count of similar messages beside 

we were unable to process you request.   total count of similar messages beside

Unable to locate user                                         total count of similar messages beside

 

PLease suggest a solution

Tags (2)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @REACHGPRAVEEN,

Please try below;

| eval errormsg=if(errormessages LIKE "user % not found","user not found","")
| stats sum(total) as total by errormsg
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...