<?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 Alerts and Nested Searches in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71599#M992</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have a system which performs some averaging on a 30 minute window of data coming in based on a data feed using this search. (We will call this &lt;STRONG&gt;search A&lt;/STRONG&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="reports" REGIONID=NSW1 earliest=-60m latest=+60m | dedup _time,REGIONID  | eval currentPeriodHour = strftime(now(), "%H") | eval currentPeriodMin = strftime(now(), "%M") | eval currentPeriod=floor((currentPeriodHour*60+currentPeriodMin)/30)+1 | eval period=floor((date_hour*60+date_minute-5)/30)+1 | eval inCurrentPeriod = if(currentPeriod == period, "t", "f") | search inCurrentPeriod="t" | stats avg(RRP) as avg, max(_time) as _time by REGIONID,period, currentPeriod, currentPeriodHour, currentPeriodMin  | table period, currentPeriod, currentPeriodHour, currentPeriodMin, REGIONID, avg, _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Trust me that search works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Now this is part of an alert with a custom condition of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search REGIONID=NSW1 avg &amp;lt; 50
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is that this alert pretty much fires all the time. I would only like it to fire if another search is met based on a completely unrelated set of data. (We will call this &lt;STRONG&gt;search B&lt;/STRONG&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=holdingRegisters SPLUNK=StationStatusCoil station=hunter | dedup station | search stationStatus &amp;gt;= 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So is it possible to even do this? Each search has completely independent data sets so merging them into the one search would be difficult. Not only that it would make Splunk work even harder than it should need to.&lt;/P&gt;

&lt;P&gt;Preferably I would like to perform &lt;STRONG&gt;search B&lt;/STRONG&gt; and if that has data then perform &lt;STRONG&gt;search A&lt;/STRONG&gt; and if that has data fire the alert.&lt;/P&gt;

&lt;P&gt;Is what I am wanting to do even possible?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2012 01:53:19 GMT</pubDate>
    <dc:creator>phoenixdigital</dc:creator>
    <dc:date>2012-02-15T01:53:19Z</dc:date>
    <item>
      <title>Alerts and Nested Searches</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71599#M992</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have a system which performs some averaging on a 30 minute window of data coming in based on a data feed using this search. (We will call this &lt;STRONG&gt;search A&lt;/STRONG&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="reports" REGIONID=NSW1 earliest=-60m latest=+60m | dedup _time,REGIONID  | eval currentPeriodHour = strftime(now(), "%H") | eval currentPeriodMin = strftime(now(), "%M") | eval currentPeriod=floor((currentPeriodHour*60+currentPeriodMin)/30)+1 | eval period=floor((date_hour*60+date_minute-5)/30)+1 | eval inCurrentPeriod = if(currentPeriod == period, "t", "f") | search inCurrentPeriod="t" | stats avg(RRP) as avg, max(_time) as _time by REGIONID,period, currentPeriod, currentPeriodHour, currentPeriodMin  | table period, currentPeriod, currentPeriodHour, currentPeriodMin, REGIONID, avg, _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Trust me that search works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Now this is part of an alert with a custom condition of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search REGIONID=NSW1 avg &amp;lt; 50
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is that this alert pretty much fires all the time. I would only like it to fire if another search is met based on a completely unrelated set of data. (We will call this &lt;STRONG&gt;search B&lt;/STRONG&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=holdingRegisters SPLUNK=StationStatusCoil station=hunter | dedup station | search stationStatus &amp;gt;= 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So is it possible to even do this? Each search has completely independent data sets so merging them into the one search would be difficult. Not only that it would make Splunk work even harder than it should need to.&lt;/P&gt;

&lt;P&gt;Preferably I would like to perform &lt;STRONG&gt;search B&lt;/STRONG&gt; and if that has data then perform &lt;STRONG&gt;search A&lt;/STRONG&gt; and if that has data fire the alert.&lt;/P&gt;

&lt;P&gt;Is what I am wanting to do even possible?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2012 01:53:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71599#M992</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2012-02-15T01:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts and Nested Searches</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71600#M993</link>
      <description>&lt;P&gt;if search B meets the alert criteria it could run a script which could start the search A&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2012 15:16:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71600#M993</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2012-02-15T15:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts and Nested Searches</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71601#M994</link>
      <description>&lt;P&gt;Thanks for the response. Unfortunately this wont really work as I want the alert to trigger a script which will create control files for an external application. So both searches need to be performed before the alert fires.&lt;/P&gt;

&lt;P&gt;After some research I think I will need to make a custom search command.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/developer/searchscripts"&gt;http://docs.splunk.com/Documentation/Splunk/latest/developer/searchscripts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The documentation seems a bit loose and I have been unable to get one working yet even with examples. I will report back with a solution if I manage to get it sorted out.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2012 01:52:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71601#M994</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2012-02-20T01:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts and Nested Searches</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71602#M995</link>
      <description>&lt;P&gt;Just a heads up that this issue has been resolved with a custom search command.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2012 00:55:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-and-Nested-Searches/m-p/71602#M995</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2012-03-23T00:55:26Z</dc:date>
    </item>
  </channel>
</rss>

