<?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: Refining alert using per $result.host$ -- How to generate separate alerts per host? in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276731#M5097</link>
    <description>&lt;P&gt;you could script this in your search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval sendTo=if(case(host==host1,"user@domain.tld",host==host2,"user2@domain.tld")) | where count&amp;gt;0 | sendemail to=$result.sendTo$ ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not certain the sendTo command is correct in my example but it sounds like you can figure it out from there.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jun 2016 10:41:25 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-06-01T10:41:25Z</dc:date>
    <item>
      <title>Refining alert using per $result.host$ -- How to generate separate alerts per host?</title>
      <link>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276730#M5096</link>
      <description>&lt;P&gt;I have a need to generate alerts from a single scheduled search:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Show me all the events PER HOST matching my condition&lt;/LI&gt;
&lt;LI&gt;Send a separate alert PER HOST&lt;/LI&gt;
&lt;LI&gt;Email a different user PER HOST&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Can this be done without external scripts?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2016 03:03:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276730#M5096</guid>
      <dc:creator>the_wolverine</dc:creator>
      <dc:date>2016-06-01T03:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Refining alert using per $result.host$ -- How to generate separate alerts per host?</title>
      <link>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276731#M5097</link>
      <description>&lt;P&gt;you could script this in your search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval sendTo=if(case(host==host1,"user@domain.tld",host==host2,"user2@domain.tld")) | where count&amp;gt;0 | sendemail to=$result.sendTo$ ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not certain the sendTo command is correct in my example but it sounds like you can figure it out from there.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2016 10:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276731#M5097</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-06-01T10:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Refining alert using per $result.host$ -- How to generate separate alerts per host?</title>
      <link>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276732#M5098</link>
      <description>&lt;P&gt;If you need to send a contextually-approrpriate subset of results to some people, you can skip the configuration-based email settings and do this in SPL directly:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | outputcsv TempFile.csv
| stats values(Email_Address) AS emailToHeader | mvexpand emailToHeader
| map search="|inputcsv TempFile.csv | where Email_Addresss=\"$emailToHeader$\"
   | fields - Email_Address
   | sendemail
      sendresults=true inline=true
      server=\"Your.Value.Here\"
      from=\"Your.Value.Here\"
      to=\"$emailToHeader$\"
      subject=\"Your Subject here: \$name\$\"
      message=\"This report alert was generated by \$app\$ Splunk with this search string: \$search\$\""
| search ThisFieldWillNeverExist="SoThisCommandWillDropAllEventsSoThatYouCanPullInTheOriginalSetWhichYouMightOrMightNotCareToDo"
| appendpipe [|inputcsv TempFile.csv]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The only downside to this approach is that If the search dose not return any results it will produce the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error in "map": Did not find value for required attributes 'emailToHeader'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is "normal" and I have not found a good way to code around it.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2016 13:04:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276732#M5098</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-01T13:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Refining alert using per $result.host$ -- How to generate separate alerts per host?</title>
      <link>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276733#M5099</link>
      <description>&lt;P&gt;Configure the saved search.&lt;BR /&gt;
Use a lookup in the search, that matches the email recipient to the alert they need to recieve. &lt;/P&gt;

&lt;P&gt;Schedule it to alert. &lt;BR /&gt;
Set alert mode per-result.&lt;BR /&gt;&lt;BR /&gt;
Set alert action send email&lt;BR /&gt;
Set email recipient token from the event as the sendto field. &lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 20:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Refining-alert-using-per-result-host-How-to-generate-separate/m-p/276733#M5099</guid>
      <dc:creator>solarboyz1</dc:creator>
      <dc:date>2018-05-17T20:50:28Z</dc:date>
    </item>
  </channel>
</rss>

