Splunk Search

Count occurrence of message in table

Nilesh067
Explorer

I have a message feild having below data 

 

message=Successfully created  customer id XXXX

message =Duplicate create  customer id XXXX

message=Error while create customer id XXXX

message=Successfully updated customer id XXXX

message=Error while updating  customer id  XXXX

 

can we display it in the below format.

Message                                                               Count

Successfully created  customer id              1

Duplicate create  customer id                        1

Error while create customer id                       1

Successfully updated customer id                1 

Error while updating  customer id                  1

 

if not found the count must be 0

 

 

Labels (6)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=message "(?<type>(Successfully created|Duplicate create|Error while create|Successfully updated|Error while updating) customer id)"
| stats count by type
| append [| makeresults | eval type="Successfuly created customer id", count=0 | fields type, count ]
| append [| makeresults | eval type="Duplicate create customer id", count=0 | fields type, count ]
| append [| makeresults | eval type="Error while create customer id", count=0 | fields type, count ]
| append [| makeresults | eval type="Successfully updated customer id", count=0 | fields type, count ]
| append [| makeresults | eval type="Error while updating customer id", count=0 | fields type, count ]
| stats sum(count) as count by type​
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...