Splunk Search

Subsearch calculating average of hits and showing list of values higher than the average?

changwoo
Communicator

I am trying to make a subsearch which calculates the avg of the hits .
And showing the list of higher value than the avg.

i tried the search like this :
index= temp sourcetype = searchlog [search index = temp sourcetype = searchlog |stats avg(searchKeyword.hits) as avg | fields avg] | table avg

What's the problem ?

Tags (3)
1 Solution

Suda
Communicator

Hello,

Could you try to use "eventstats"?

I think the "Example 3" of eventstats would be the same as your requirement.

http://docs.splunk.com/Documentation/Splunk/6.1.2/SearchReference/Eventstats

index=temp sourcetype=searchlog | eventstats avg(searchKeyword.hits) AS avg | where searchkeyword.hits > avg

I hope it helps you. Happy splunking!

View solution in original post

Suda
Communicator

Hello,

Could you try to use "eventstats"?

I think the "Example 3" of eventstats would be the same as your requirement.

http://docs.splunk.com/Documentation/Splunk/6.1.2/SearchReference/Eventstats

index=temp sourcetype=searchlog | eventstats avg(searchKeyword.hits) AS avg | where searchkeyword.hits > avg

I hope it helps you. Happy splunking!

changwoo
Communicator

Thanks!!! it works perfect!!!

martin_mueller
SplunkTrust
SplunkTrust

Note, you need to enclose searchKeyword.hits in single quotes for the where (and the RHS of eval) commands:

... | where 'searchKeyword.hits' > avg

Else the command will interpret the dot as the string concatenation operator.

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...