<?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 a problem about sub search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20556#M3234</link>
    <description>&lt;P&gt;Hi~  masters&lt;BR /&gt;
There is  case as:&lt;BR /&gt;
When events count of last 5 min is greater than an average count of 1 hour before (count-of-1h/12), trigger a email alert&lt;BR /&gt;
I tried this:&lt;BR /&gt;
summary index:&lt;BR /&gt;
index="_internal" | fields | sistats count&lt;BR /&gt;
named Count5magain1h, scheduled every 5min, then:&lt;BR /&gt;
index=summary search_name=Count5magain1h | sort -_time limit=13 |stats count| rename count as countof65m | &lt;BR /&gt;
eval Average = (countof65m - [search index=summary search_name=Count5magain1h | sort -_time limit=1 | stats count | rename count as countof5m | return countof5m])/12 |&lt;BR /&gt;
eval Result=case(countof5m&amp;gt;2*Average,1,countof5m&amp;lt;2*Average,0) &lt;/P&gt;

&lt;P&gt;this seems not going to work! I must have mistaken syntax of search&lt;BR /&gt;
Could someone help me  thanks~&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 12:09:56 GMT</pubDate>
    <dc:creator>crazyeva</dc:creator>
    <dc:date>2020-09-28T12:09:56Z</dc:date>
    <item>
      <title>a problem about sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20556#M3234</link>
      <description>&lt;P&gt;Hi~  masters&lt;BR /&gt;
There is  case as:&lt;BR /&gt;
When events count of last 5 min is greater than an average count of 1 hour before (count-of-1h/12), trigger a email alert&lt;BR /&gt;
I tried this:&lt;BR /&gt;
summary index:&lt;BR /&gt;
index="_internal" | fields | sistats count&lt;BR /&gt;
named Count5magain1h, scheduled every 5min, then:&lt;BR /&gt;
index=summary search_name=Count5magain1h | sort -_time limit=13 |stats count| rename count as countof65m | &lt;BR /&gt;
eval Average = (countof65m - [search index=summary search_name=Count5magain1h | sort -_time limit=1 | stats count | rename count as countof5m | return countof5m])/12 |&lt;BR /&gt;
eval Result=case(countof5m&amp;gt;2*Average,1,countof5m&amp;lt;2*Average,0) &lt;/P&gt;

&lt;P&gt;this seems not going to work! I must have mistaken syntax of search&lt;BR /&gt;
Could someone help me  thanks~&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20556#M3234</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2020-09-28T12:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: a problem about sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20557#M3235</link>
      <description>&lt;P&gt;So I am not sure I understand your question, but try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere earliest=-65m latest=-5m
| bucket _time span=5m
| stats count as FiveMinCount by _time
| stats avg(FiveMinCount) as avgCount
| appendcols [ search yoursearchhere  earliest=-5m
   | stats count as currentCount ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't understand why you are searching the _internal index. In my example above, I have inserted &lt;CODE&gt;yoursearchhere&lt;/CODE&gt; where your search criteria should go.&lt;/P&gt;

&lt;P&gt;Also your custom condition on the alert should be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;where currentCount &amp;gt; avgCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 05:02:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20557#M3235</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-07-30T05:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: a problem about sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20558#M3236</link>
      <description>&lt;P&gt;Thank you very much! I am not good at expressing...&lt;BR /&gt;
But that exactly solved my problem, and helped me with the usage of Splunk&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2012 03:54:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/a-problem-about-sub-search/m-p/20558#M3236</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-07-31T03:54:03Z</dc:date>
    </item>
  </channel>
</rss>

