<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help with multiple time-frame searches... in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40533#M9336</link>
    <description>&lt;P&gt;First off, I want to thank you and all the other folks who have answered my slews of questions.  The Splunk community is incredibly supportive!  &lt;/P&gt;

&lt;P&gt;Does the "where count &amp;gt; threshold" command add up the contents of the preceding minutes?  Let's say the failed login count looks like the following (minsago,src_ip,count):  &lt;/P&gt;

&lt;P&gt;0,192.168.1.1,4&lt;BR /&gt;
1,192.168.1.1,25&lt;BR /&gt;&lt;BR /&gt;
2,192.168.1.1,30&lt;BR /&gt;&lt;BR /&gt;
3,192.168.1.1,1100&lt;BR /&gt;&lt;BR /&gt;
4,192.168.1.1,25&lt;BR /&gt;&lt;BR /&gt;
5,192.168.1.1,11   &lt;/P&gt;

&lt;P&gt;If the count of events crosses the threshold at minsago=3, will that search show that at the end of minsago=4 the count of events was 1159?&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2011 11:39:24 GMT</pubDate>
    <dc:creator>jambajuice</dc:creator>
    <dc:date>2011-02-08T11:39:24Z</dc:date>
    <item>
      <title>Help with multiple time-frame searches...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40531#M9334</link>
      <description>&lt;P&gt;I'm looking to create a large number of searches that will identify suspicious security events.  An example of the logic would be as follows:  &lt;/P&gt;

&lt;P&gt;If the number of failed logins from src_ip in the first minute is &amp;gt; 3, set priority to 2.  If the number of failed logins from src_ip in the first 3 minutes is &amp;gt; 100, set priority to 5.  If the number of failed logins from src_ip in the first to minutes is &amp;gt; 1000, set priority to 9.  &lt;/P&gt;

&lt;P&gt;This kind of logic would capture a brute force login attack with increasing confidence.  &lt;/P&gt;

&lt;P&gt;What is the best way to implement something like this without having to schedule hundreds of searches (assuming you want to monitor a large variety of suspicious events)?  I've been experimenting with a search like this:  &lt;/P&gt;

&lt;P&gt;host="192.168.198.1" earliest=-5m [search * earliest=-5m latest=-4m | stats count by src_ip,dest_ip,dest_port | rename count AS count1] | stats count by src_ip,dest_ip,dest_port | table src_ip,dest_ip,dest_port,count1,count  &lt;/P&gt;

&lt;P&gt;This search ran for a very, very long time.  Far longer than the 5 minutes it was looking at.  Would a better approach be to run saved searches that collect stats on the events in question and save them to either a lookup table or summary index for use by other searches that would apply the logic?  &lt;/P&gt;

&lt;P&gt;Is it possible to run a search with a latest= value that is in the future?  I can see implementing something like this:  A search runs every minute and checks the event id against a lookup table to see if that event triggers a more complex search.  If so, it returns the search string.  If there is a match, the event is piped to the search string returned from the lookup table with a latest= value x minutes into the future.  That search would run until the latest= value is met and then use eval or stats to apply the logical tests.  Ideally that final search could be sent to the background so the next event with a positive match in the lookup table can be processed.  &lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;

&lt;P&gt;Craig&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 09:06:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40531#M9334</guid>
      <dc:creator>jambajuice</dc:creator>
      <dc:date>2011-02-08T09:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multiple time-frame searches...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40532#M9335</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-5m "failed login" 
| timechart count by src_ip 
| eval minsago=floor((now()-_time)/60) 
| lookup threshold_table minsago OUTPUT threshold priority
| where count &amp;gt; threshold
| stats max(priority) as priority by src_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And threshold table as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;minsago,threshold,priority
0,3,2
2,100,5
4,1000,9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;seems like it would fit the textual description. &lt;/P&gt;

&lt;P&gt;As far as time range, yes you can search for events in the future, but it sounds more like you really want to use real-time searches (or real-time alerts once 4.2 is out)&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Update: You can just add in a &lt;CODE&gt;streamstats&lt;/CODE&gt; command to get the cumulative count:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-5m "failed login" 
| bucket _time span=1m
| stats count by _time,src_ip
| sort + _time
| streamstats current=t window=0 global=f
     sum(count) as count by src_ip
| eval minsago=floor((now()-_time)/60) 
| lookup threshold_table minsago OUTPUT threshold priority
| where count &amp;gt; threshold
| stats max(priority) as priority by src_ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2011 09:29:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40532#M9335</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-02-08T09:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multiple time-frame searches...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40533#M9336</link>
      <description>&lt;P&gt;First off, I want to thank you and all the other folks who have answered my slews of questions.  The Splunk community is incredibly supportive!  &lt;/P&gt;

&lt;P&gt;Does the "where count &amp;gt; threshold" command add up the contents of the preceding minutes?  Let's say the failed login count looks like the following (minsago,src_ip,count):  &lt;/P&gt;

&lt;P&gt;0,192.168.1.1,4&lt;BR /&gt;
1,192.168.1.1,25&lt;BR /&gt;&lt;BR /&gt;
2,192.168.1.1,30&lt;BR /&gt;&lt;BR /&gt;
3,192.168.1.1,1100&lt;BR /&gt;&lt;BR /&gt;
4,192.168.1.1,25&lt;BR /&gt;&lt;BR /&gt;
5,192.168.1.1,11   &lt;/P&gt;

&lt;P&gt;If the count of events crosses the threshold at minsago=3, will that search show that at the end of minsago=4 the count of events was 1159?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 11:39:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40533#M9336</guid>
      <dc:creator>jambajuice</dc:creator>
      <dc:date>2011-02-08T11:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multiple time-frame searches...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40534#M9337</link>
      <description>&lt;P&gt;Even though in minsago=4, there were only 25 events during that minute?  How can I sum the events from the time window defined by the earliest _time + minsago?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 11:47:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40534#M9337</guid>
      <dc:creator>jambajuice</dc:creator>
      <dc:date>2011-02-08T11:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multiple time-frame searches...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40535#M9338</link>
      <description>&lt;P&gt;add the &lt;CODE&gt;streamstats&lt;/CODE&gt; command as in the update above to accumulate the sum.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 14:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40535#M9338</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-02-08T14:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multiple time-frame searches...</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40536#M9339</link>
      <description>&lt;P&gt;actually, i guess using &lt;CODE&gt;timechart&lt;/CODE&gt; won't quite work. i rewrote it using &lt;CODE&gt;stats&lt;/CODE&gt; instead.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 14:16:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-multiple-time-frame-searches/m-p/40536#M9339</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-02-08T14:16:45Z</dc:date>
    </item>
  </channel>
</rss>

