Splunk Search

How to calculate percentage based on 3 different searches with Joins? Is that possible?

francine0
New Member

First query:

 

index="raw_es2" app message="[Login][Password]Login simplified active."
| stats count by message
| rename count as "Calls"
| table Calls

 

Second Query:

 

index="raw_es2" app message="[Login][Password]Login simplified active."
| table flowId
    | join type=inner flowId
[
 search index"raw_es2" app message="[Login][Password] finished."
]
| stats count by message
| rename count as "Success"
| table Success

 

 Third Query:

 

index="raw_es2" app message="[Login][Password]Login simplified active."
| table flowId
    | join type=inner flowId
[
 search index"raw_es2" app message="[Login][Password] finished with error."
]
| stats count by message
| rename count as "Errors"
| table Errors

 

 

Is that possible I put the result of each query in a eval to calculate the percentage of error and success?
Something like:

 

| stats sum(calls), sum(success), sum(errors)
| eval error percentage = round(success*100/Calls)
| eval success percentage = round(errors*100/Calls)
| eval "error percentage" > 0

 

 

The gold would be to have an answer like this all at once: 

 

Calls:  Success:   Errors:   PercentualErrors:    PercentualSuccess:
   299       285        14                4.68                 95.32

 

 

Labels (3)
Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @francine0,

you coud try a different approach:

index="raw_es2" (message="[Login][Password]Login simplified active." OR message="[Login][Password]Login simplified active." OR message="[Login][Password]Login simplified active.")
| eval action=case(message="[Login][Password]Login simplified active.", "Start", message="[Login][Password]Login simplified active.", "Success", message="[Login][Password]Login simplified active.", "Error")
| stats 
   count(eval(action="Start")) AS Calls
   count(eval(action="Success")) AS Success
   count(eval(action="Error")) AS Error
| eval 
   PercentualErrors=round(Error/Calls*100,2),
   PercentualSuccess=round(Success/Calls*100,2)
| table Calls Success Error PercentualErrors PercentualSuccess

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...