Splunk Search

How to edit my stats search to find the percentage of a range?

dcascione
Explorer

I'm trying to build a simple SPL query to display the max, min, range (difference), and percent of the difference to the max value.

index=myindex source="mysource"| stats max(count), min(count), range(count)|rename max(count) to "Max", min(count) to "Min", range(count) to "Difference"

Tried using the perc(y) stats function with no luck... Also tried some basic math which blows up every time..

range(count) \ max(count)*100 

Thanks for your help in advance.

0 Karma
1 Solution

javiergn
Super Champion

Hi, is count an existing field in your data?
If so try the following:

index=myindex source="mysource"
| stats max(count) as Max, min(count) as Min, range(count) as Difference
| eval Difference_Percent = Difference / Max * 100

If not, you need to calculate the value of count first (probably using stats count)

View solution in original post

0 Karma

javiergn
Super Champion

Hi, is count an existing field in your data?
If so try the following:

index=myindex source="mysource"
| stats max(count) as Max, min(count) as Min, range(count) as Difference
| eval Difference_Percent = Difference / Max * 100

If not, you need to calculate the value of count first (probably using stats count)

0 Karma

dcascione
Explorer

Yes -"count" is an existing field . This worked - Thanks for the answer!

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...