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 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...