Splunk Search

How to get sum of all the results

dpdwibedy
Explorer

Hi All,

I'm using a query to get the total total count of  a filed ( different error messages ) .
Here is the search and stats being displayed:

 

index=sp_dev  "ProductHandler" | rex field=message "operation\\\":\\\"(?<ErrorMessage>[A-Za-z]+)\\\""| stats count by ErrorMessage

ErrorMessage Count

ProductNotFound         10

DuplicateProduct          36

InvalidProductCode     18

 

I want  the total number of  these 3 error messages   as  TotalErrors.

Thanks,

DD

Labels (1)
0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust

Then the best option is add to the end (w/o addcoltotals)

| stats sum(Count) as TotalError

r. Ismo

View solution in original post

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

Add the next line to end of your query

| addcoltotals labelfield=ErrorMessage Count

r. Ismo

0 Karma

dpdwibedy
Explorer

@isoutamo  : I am seeing same result as mine.

I want  only one column with count.

 

TotalError     

40

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Then the best option is add to the end (w/o addcoltotals)

| stats sum(Count) as TotalError

r. Ismo

0 Karma

dpdwibedy
Explorer

Thanks! . That worked.

0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...