Splunk Search

eval and "|search" question

cpeteman
Contributor

So I have a search that runs over a 4h time span that Only gives results when the number of event of one kind are as manhy as or more than the number of hours. I want to be able to run over any timespan:

    search terms earliest=-4h latest=now() | ... |  stats count by _raw,TimeInHour,punct| 
 addinfo| eval hours = round((info_max_time - info_min_time)/3600,0) | search count > 3

the search should look for results that have a count equal to the number of hours I searched over but if I write

   search terms earliest=-4h latest=now() | ... |  stats count by _raw,TimeInHour,punct  |addinfo
| eval hours = round((info_max_time - info_min_time)/3600,0) | search count > hours-1

I get no results. Are count and hours not something I can compare, how do I change that?

Tags (2)
1 Solution

davecroto
Splunk Employee
Splunk Employee

rename count "AS" something else and then use that something else to compare.

...|stats count AS foobar by _time |where foobar>25

View solution in original post

0 Karma

davecroto
Splunk Employee
Splunk Employee

rename count "AS" something else and then use that something else to compare.

...|stats count AS foobar by _time |where foobar>25

0 Karma

cpeteman
Contributor

changing search to where was all it took. Thanks!

0 Karma

emechler_splunk
Splunk Employee
Splunk Employee

It depends on how you're getting 'count'... Maybe this search will work for you?

search terms earliest=-4h | eventstats count | addinfo | eval hours = round((info_max_time - info_min_time)/3600,0) | where count > hours

0 Karma

cpeteman
Contributor

no it's from a stats pipe I''l add that part of the search.

0 Karma

linu1988
Champion

Is count a field in the event?

and why do u use search count > hours-1? why not where count > hours-1. And rather than round could you use "floor"?

Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...