<?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 Email alerts with logics in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278439#M12550</link>
    <description>&lt;P&gt;For example, I want to accomplish this with only one alert saved search: to send email notification to admin_a if the search returns between 10 and 100 events within 5 mins (or when the search is ran), but to run some additional scripts or send email alert to admin_a and manager, if more than 100 events returned within 5 minutes.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 07:36:21 GMT</pubDate>
    <dc:creator>tsunamii</dc:creator>
    <dc:date>2020-09-29T07:36:21Z</dc:date>
    <item>
      <title>Email alerts with logics</title>
      <link>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278439#M12550</link>
      <description>&lt;P&gt;For example, I want to accomplish this with only one alert saved search: to send email notification to admin_a if the search returns between 10 and 100 events within 5 mins (or when the search is ran), but to run some additional scripts or send email alert to admin_a and manager, if more than 100 events returned within 5 minutes.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:36:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278439#M12550</guid>
      <dc:creator>tsunamii</dc:creator>
      <dc:date>2020-09-29T07:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Email alerts with logics</title>
      <link>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278440#M12551</link>
      <description>&lt;P&gt;There are several things mixed up here, so I'll try to untangle.&lt;/P&gt;

&lt;P&gt;First I'll assume you have a search that returns some &lt;CODE&gt;count&lt;/CODE&gt; field in an event, and you want to alert if &lt;CODE&gt;count &amp;gt;= 10&lt;/CODE&gt;. To do that, you can either add &lt;CODE&gt;| where count &amp;gt;= 10&lt;/CODE&gt; to your search and alert on "search returns an event", or add the &lt;CODE&gt;where count &amp;gt;= 10&lt;/CODE&gt; as the alert condition.&lt;BR /&gt;
If you actually have the events returned from your search, you can instead set the alert condition to "alert if number of events is greater than" and enter your number.&lt;/P&gt;

&lt;P&gt;Second, you want to email different people depending on the count. Set your email recipient to &lt;CODE&gt;$result.recipient$&lt;/CODE&gt; and add this to your search: &lt;CODE&gt;... | eval recipient = if (count &amp;lt; 100, "admin_a@example.com", "admin_a@example.com,manager@example.com")&lt;/CODE&gt;&lt;BR /&gt;
If you're actually returning events, add this instead: &lt;CODE&gt;... | eventstats count | eval if(...)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Third, you want to run a script based on the count, but don't want a second alert. Run the script every time, and let the script abort if the &lt;CODE&gt;count&lt;/CODE&gt; is below the threshold. If you can't modify your script then create a simple wrapper script to make this decision.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2015 19:43:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278440#M12551</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-10-12T19:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Email alerts with logics</title>
      <link>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278441#M12552</link>
      <description>&lt;P&gt;This appears to work on splunk 6.3: &lt;/P&gt;

&lt;P&gt;"error" | stats count | eval recipient=case(count &amp;gt; 3500, "&lt;A href="mailto:recipient1@domain.com"&gt;recipient1@domain.com&lt;/A&gt;", count &amp;gt;= 500, "&lt;A href="mailto:recipient2@domain.com"&gt;recipient2@domain.com&lt;/A&gt;", 1==1, null()) | where isnotnull(recipient) &lt;/P&gt;

&lt;P&gt;AND in the to field you specify: &lt;BR /&gt;
$result.recipient$ &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;So this says, &lt;/P&gt;

&lt;P&gt;if we have &amp;gt; 3500 records then &lt;BR /&gt;
send to recipient1 &lt;BR /&gt;
else if you have &amp;gt; 500 records &lt;BR /&gt;
then send to recipient 2 &lt;BR /&gt;
else &lt;BR /&gt;
do not send any mail (sets recipient to null)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 18:33:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278441#M12552</guid>
      <dc:creator>splunkIT</dc:creator>
      <dc:date>2016-01-14T18:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Email alerts with logics</title>
      <link>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278442#M12553</link>
      <description>&lt;P&gt;The latest doc has been updated with this information:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Alert/Emailnotification#Send_email_notification_from_a_search_command"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Alert/Emailnotification#Send_email_notification_from_a_search_command&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 19:20:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Email-alerts-with-logics/m-p/278442#M12553</guid>
      <dc:creator>splunkIT</dc:creator>
      <dc:date>2016-02-19T19:20:00Z</dc:date>
    </item>
  </channel>
</rss>

