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!

Announcing Scheduled Export GA for Dashboard Studio

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

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...