Splunk Search

How to get results of two searches and compare them?

sheldonkooper
Engager

i have two searches:

earliest=-10m index=perfmon server=web1  sourcetype="Perfmon:CPUTime" | stats avg(Value) as CPUUtilisation | sort -CPUUtilisation | stats first(CPUUtilisation)

and

earliest=-10m index=perfmon server=web2 sourcetype="Perfmon:CPUTime" | stats avg(Value) as CPUUtilisation | sort -CPUUtilisation | stats first(CPUUtilisation)

I got the Search 1 result as 25.5 and Search 2 result as 30.5
1. How do i compare these two values like "search2-search1=5" or "search2+search1=56"?
2. can i store search1, search2 values in some variable like $result1 ,$result2

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

This will do it:

earliest=-10m index=perfmon sourcetype="Perfmon:CPUTime" |stats avg(Value) as CPUUtilisation| sort -CPUUtilisation|stats first(CPUUtilisation) BY server | transpose | search column ="count" | eval sum = $row 1$ + $row 2$ | eval diff = $row 1$ - $row 2$

View solution in original post

woodcock
Esteemed Legend

This will do it:

earliest=-10m index=perfmon sourcetype="Perfmon:CPUTime" |stats avg(Value) as CPUUtilisation| sort -CPUUtilisation|stats first(CPUUtilisation) BY server | transpose | search column ="count" | eval sum = $row 1$ + $row 2$ | eval diff = $row 1$ - $row 2$

sheldonkooper
Engager

got the idea. Thanks 🙂

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, ...