<?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: count something with a specifc rule and time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336773#M164426</link>
    <description>&lt;P&gt;@adonio - Slight issue with this one... if there are ten within an hour, but an eleventh outside of that hour, this one will give a false negative. &lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2017 14:35:33 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-12-13T14:35:33Z</dc:date>
    <item>
      <title>count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336768#M164421</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have many lines of event like these two:&lt;BR /&gt;
2017 12 07 21:32:23.669 | 20,3329788638103|CT02053,15.96x11.81x6.15,211 lbs&lt;BR /&gt;
2017 12 07 21:29:26.648 | 19,42233978863257|CT02010,16.26x15.43x16.75,4441 lbs&lt;/P&gt;

&lt;P&gt;Each event starts with a time, then a bunch of random number and code, and ends with the weight in "lbs"(the weight is the number before the "lbs"). I need to accomplish two goals:&lt;BR /&gt;
1. Count if same weight happens over in 10 events&lt;BR /&gt;
2. Count those events found from #1 if they are happened within 10 minutes based on their time stamps.&lt;/P&gt;

&lt;P&gt;I use this query to achieve goal #1. &lt;BR /&gt;
Base search..........| use rex command to create the field for the weight | stats count by weight | where count&amp;gt;10&lt;/P&gt;

&lt;P&gt;But I don't know how I can confirm the time of those events are happens within 10 minutes?&lt;BR /&gt;
I tried to add "transaction weight maxspan=10m" at the end of the query but it didn't work. Any idea?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 02:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336768#M164421</guid>
      <dc:creator>splunkinsfs</dc:creator>
      <dc:date>2017-12-12T02:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336769#M164422</link>
      <description>&lt;P&gt;Here's one approach... use &lt;CODE&gt;streamstats&lt;/CODE&gt; to count how many are in a 10m &lt;CODE&gt;time_window&lt;/CODE&gt; for each weight.  Once that pass is complete, use &lt;CODE&gt;eventstats&lt;/CODE&gt; to copy the highest &lt;CODE&gt;count&lt;/CODE&gt; found in each &lt;CODE&gt;weight&lt;/CODE&gt; onto each record that has that &lt;CODE&gt;weight&lt;/CODE&gt;, and use that to eliminate events that did not reach the threshold.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search..........
| use rex command to create the field for the weight 
| fields weight
| sort 0 _time 
| streamstats time_window=10m count as mycount by weight
| eventstats max(mycount) as maxcount by weight
| where maxcount&amp;gt;10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After the above, you have only &lt;CODE&gt;weights&lt;/CODE&gt; that occurred at least 10 times within a 10m period, but you have all examples of that &lt;CODE&gt;weight&lt;/CODE&gt;, whether they were in such a period or not.  If you then want to &lt;CODE&gt;stats&lt;/CODE&gt; them and have the earliest &lt;CODE&gt;_time&lt;/CODE&gt;, latest &lt;CODE&gt;_time&lt;/CODE&gt;, and the total number of occurrences, you can do that.  If you want to do other analysis, you can do that. &lt;/P&gt;

&lt;P&gt;If you want to get rid of all records that are NOT members of a set of at least ten within ten minutes, then you are going to have to &lt;CODE&gt;reverse&lt;/CODE&gt; the list and process them backwards.  That would look something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| reverse
| eval tenflag=case(mycount&amp;gt;=10,"Y")
| streamstats time_window=10m max(tenflag) as tenflag by weight
| where tenflag="Y"
| reverse
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2017 03:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336769#M164422</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-12-12T03:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336770#M164423</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;your_search_here&amp;gt; 
    | rex &amp;lt;your_rex_here&amp;gt;
    | stats count as weight_count latest(_time) as last_one earliest(_time) as first_one by weight
    | eval duration=last_one-first_one
    | where weight_count&amp;gt;10 AND duration&amp;lt;600
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope i understood your question&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 03:22:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336770#M164423</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-12-12T03:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336771#M164424</link>
      <description>&lt;P&gt;Thanks for the quick suggestion. The result of your query did bring up the result that I need. &lt;/P&gt;

&lt;P&gt;Again, I was looking for&lt;BR /&gt;
1. Count if same weight happens over 10 times&lt;BR /&gt;
2. Count among from those events found from #1 if they are happened within 10 minutes based on the event time.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 04:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336771#M164424</guid>
      <dc:creator>splunkinsfs</dc:creator>
      <dc:date>2017-12-12T04:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336772#M164425</link>
      <description>&lt;P&gt;Thanks for the suggestion. Your query seems to be working . I'll do additional stats count to make the final result looks good. &lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 15:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336772#M164425</guid>
      <dc:creator>splunkinsfs</dc:creator>
      <dc:date>2017-12-12T15:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336773#M164426</link>
      <description>&lt;P&gt;@adonio - Slight issue with this one... if there are ten within an hour, but an eleventh outside of that hour, this one will give a false negative. &lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 14:35:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336773#M164426</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-12-13T14:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: count something with a specifc rule and time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336774#M164427</link>
      <description>&lt;P&gt;yup...&lt;BR /&gt;
thanks for pointing out, forgot about the time_window in streamstats.&lt;BR /&gt;
appreciate your feedback and answers!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 15:26:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-something-with-a-specifc-rule-and-time/m-p/336774#M164427</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-12-13T15:26:18Z</dc:date>
    </item>
  </channel>
</rss>

