<?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: Alerts based on result range in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340468#M10793</link>
    <description>&lt;P&gt;Not a problem! If that's the case, there are two ways you can go:&lt;BR /&gt;
1) Create a custom Python command &lt;CODE&gt;sendslack&lt;/CODE&gt; that posts the results to Slack and use the same logic as Option 2 above.&lt;BR /&gt;
2) Take a look at the third option I mentioned above. While it requires a scheduled search and two alerts, the two alerts are basically free in terms of performance/load. All you need is a very simply KVstore that has one field: last_count. So your main savedsearch would basically be &lt;CODE&gt;... | stats count | rename count | outputlookup alert_count_lookup&lt;/CODE&gt;. and each alert query would just be &lt;CODE&gt;| inputlookup alert_count_lookup | search count&amp;gt;x count&amp;lt;y+1&lt;/CODE&gt;. &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:46:44 GMT</pubDate>
    <dc:creator>jonmargulies</dc:creator>
    <dc:date>2020-09-29T13:46:44Z</dc:date>
    <item>
      <title>Alerts based on result range</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340465#M10790</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to set up alerts based on number of results we received from a search.&lt;/P&gt;

&lt;P&gt;If the number of results returned is between x-y, need to send to a particular set of recipient&lt;BR /&gt;
If the number of results returned is between (y+1)-z, need to send to a different set of recipient&lt;/P&gt;

&lt;P&gt;But now, I'm not able to do this in the alert. Someone able to do this ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Prabhu&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 20:02:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340465#M10790</guid>
      <dc:creator>prabhuanandampu</dc:creator>
      <dc:date>2017-04-20T20:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts based on result range</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340466#M10791</link>
      <description>&lt;P&gt;I can think of two ways of doing this:&lt;BR /&gt;
1) The easiest, but most inefficient, option is to set up two almost identical alerts. Both alerts would run the same search at the same time, but they'd have different actions. One alert would have an action with one range (x-y), and send to the first set of recipients, and the second alert would use the same query about have the other range ((y+1)-z), and send to the second set of recipients. The problem with this option, of course, is running twice as many searches as you need to.&lt;BR /&gt;
2) Instead of an alert, create a saved search that uses the &lt;CODE&gt;| sendemail&lt;/CODE&gt; command (that's basically what an alert is anyway). Basically what you can do is have an eval that sets a "to" field based on the ranges. Your query would end up looking roughly like &lt;CODE&gt;... | stats count | eval to=case(count&amp;gt;10, "address1, address2", count&amp;gt;5, "address3, address4", 1=1, "") | sendemail to="$result.to$" from="sender@example.net" subject="test" message="test2"&lt;/CODE&gt;. If the to field is empty, (i.e., count&amp;lt;5), nothing will send.&lt;/P&gt;

&lt;P&gt;Here's a Splunk Answers post that describes how to use &lt;CODE&gt;sendemail&lt;/CODE&gt; this way: &lt;A href="https://answers.splunk.com/answers/213340/how-to-get-splunk-sendemail-command-to-send-multip.html"&gt;https://answers.splunk.com/answers/213340/how-to-get-splunk-sendemail-command-to-send-multip.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;A third option is basically a more efficient version of option 1: make a kvstore that tracks state, and use a saved search to populate that kvstore. Then create two alerts that just check that kvstore (which is basically a zero-cost query).&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 20:34:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340466#M10791</guid>
      <dc:creator>jonmargulies</dc:creator>
      <dc:date>2017-04-20T20:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts based on result range</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340467#M10792</link>
      <description>&lt;P&gt;Second option is something nice to try it. Unfortunately, we are posting the alerts to the slack channels. So, will need to look for alternatives for sendmail. &lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 22:27:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340467#M10792</guid>
      <dc:creator>prabhuanandampu</dc:creator>
      <dc:date>2017-04-20T22:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts based on result range</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340468#M10793</link>
      <description>&lt;P&gt;Not a problem! If that's the case, there are two ways you can go:&lt;BR /&gt;
1) Create a custom Python command &lt;CODE&gt;sendslack&lt;/CODE&gt; that posts the results to Slack and use the same logic as Option 2 above.&lt;BR /&gt;
2) Take a look at the third option I mentioned above. While it requires a scheduled search and two alerts, the two alerts are basically free in terms of performance/load. All you need is a very simply KVstore that has one field: last_count. So your main savedsearch would basically be &lt;CODE&gt;... | stats count | rename count | outputlookup alert_count_lookup&lt;/CODE&gt;. and each alert query would just be &lt;CODE&gt;| inputlookup alert_count_lookup | search count&amp;gt;x count&amp;lt;y+1&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:46:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340468#M10793</guid>
      <dc:creator>jonmargulies</dc:creator>
      <dc:date>2020-09-29T13:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts based on result range</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340469#M10794</link>
      <description>&lt;P&gt;Option 1 sounds interesting&lt;BR /&gt;
&lt;A href="https://www.splunk.com/blog/2014/04/14/building-custom-search-commands-in-python-part-i-a-simple-generating-command/"&gt;https://www.splunk.com/blog/2014/04/14/building-custom-search-commands-in-python-part-i-a-simple-generating-command/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Will try that out&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 17:38:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-based-on-result-range/m-p/340469#M10794</guid>
      <dc:creator>prabhuanandampu</dc:creator>
      <dc:date>2017-04-21T17:38:51Z</dc:date>
    </item>
  </channel>
</rss>

