Splunk Search

How to add new column to chart with success rate of other columns

gsolomon11
New Member

I'm using the following search to generate the table below:

rex "<status>(?<status>.*?)<"|
search status=Incomplete OR    status=Complete OR status=Fail* |
count(status) by cRegion status

alt text

I'd like to create a fifth column which calulates the SuccessRate for each cRegion like this:

(Complete-(Failed+Incomplete)) / (Complete + Failed + Incomplete)

alt text

I've tried an assortment of different eval and stat and table expressions but cannot figure it out. Any help would be greatly appreciated! I would like to use the chart command.

Tags (1)
0 Karma
1 Solution

rjthibod
Champion

How about this?

rex "<status>(?<status>.*?)<"
| search status=Incomplete OR status=Complete OR status=Fail* 
| chart count(status) by cRegion status
| eval SuccessRate = round((Complete - (Failed + Incomplete)) / (Complete + Failed + Incomplete), 6)

View solution in original post

rjthibod
Champion

How about this?

rex "<status>(?<status>.*?)<"
| search status=Incomplete OR status=Complete OR status=Fail* 
| chart count(status) by cRegion status
| eval SuccessRate = round((Complete - (Failed + Incomplete)) / (Complete + Failed + Incomplete), 6)

gsolomon11
New Member

Wow, thank you so much!
I didn't know Splunk would know that the Complete/Failed/Incomplete parameters in the eval statement correspond to statuses and to automatically include them in the chart.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...