Monitoring Splunk

Query to get Percentage using two Queries?

Deprasad
Path Finder

I've 2 queries, 1 will give the the total no of events and the other will give the counts by error type.
I'm trying to join the two queries so that I can get the percentage of each error type.

Query 1:
index=app  "ResponseLoggingFilter" "Operation"
| stats count as Total_Transaction

Query 2:
index=app "ResponseLoggingFilter" "Operation"  NOT "OK" NOT "1041"
| rex "(?:.+message\"\:\")(?<Error_Message>.+)(?:\"\,)"
| stats count by Error_Message

Labels (1)
0 Karma
1 Solution

Deprasad
Path Finder

Thanks for this query @richgalloway ! 

It worked. Further I added the below piece of query to get the percentage.


| eval Error_Percentage=round(100*count/Total_Transaction,2)."%"
| table Error_Message,count, Error_Percentage

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

See if this helps

index=app  "ResponseLoggingFilter" "Operation"
| eventstats count as Total_Transaction
| rex "(?:.+message\"\:\")(?<Error_Message>.+)(?:\"\,)"
| eval Error_Message = if(match(_raw, "OK") OR match(_raw, "1041"), null(), Error_Message)
| stats max(Total_Transaction) as Total_Transaction, count by Error_Message
---
If this reply helps you, Karma would be appreciated.
0 Karma

Deprasad
Path Finder

Thanks for this query @richgalloway ! 

It worked. Further I added the below piece of query to get the percentage.


| eval Error_Percentage=round(100*count/Total_Transaction,2)."%"
| table Error_Message,count, Error_Percentage

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...