Splunk Search

How to compare all time average of a field value vs average for specified time range

christopheryu
Communicator

Trying to combine in a single table the all time average of a field value (data feed start is 10/19) vs its average from a time picked range:

search foo earliest=10/19/2017:0:0:0
| stats avg(rpm_average) as ALLTIME_AVG by interfaces
| eval ALLTIME_AVG=ALLTIME_AVG/1000
| eval ALLTIME_AVG=round(ALLTIME_AVG,2)
| append
[ search foo
| stats avg(rpm_average) as TIMEPICKED_AVG by interfaces
| eval TIMEPICKED_AVG=TIMEPICKED_AVG/1000
| eval TIMEPICKED_AVG=round(TIMEPICKED_AVG,2)]
| table interfaces ALLTIME_AVG TIMEPICKED_AVG

I am getting the below result but would like to combine rows (tried to MVDEDUP interfaces but did not work). Also, would like to add another column for difference.

Thank you in advance!

![alt text][1]

0 Karma
1 Solution

DalJeanis
SplunkTrust
SplunkTrust

Do it at the same time. Much more efficient.

 my search
| eval period_average =case(  test that  _time is in the period you want, rpm_average) 
| stats avg(rpm_average) as ALLTIME_AVG, avg(period_average) as TIMEPICKED_AVG by interfaces

FYI, If there were a reason not to do the above, you could just do this at the end...

| stats values(*) as * by interfaces

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Just add into your search.

YOUR_SEARCH | stats values(ALLTIME_AVG ) as ALLTIME_AVG values(TIMEPICKED_AVG) as TIMEPICKED_AVG by interfaces

christopheryu
Communicator

thank you.

0 Karma

DalJeanis
SplunkTrust
SplunkTrust

Do it at the same time. Much more efficient.

 my search
| eval period_average =case(  test that  _time is in the period you want, rpm_average) 
| stats avg(rpm_average) as ALLTIME_AVG, avg(period_average) as TIMEPICKED_AVG by interfaces

FYI, If there were a reason not to do the above, you could just do this at the end...

| stats values(*) as * by interfaces
0 Karma

christopheryu
Communicator

2nd one worked, pretty much the same as kamlesh's. Thank you.

0 Karma
Get Updates on the Splunk Community!

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

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...