<?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: Alert Email Subject Control in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Alert-Email-Subject-Control/m-p/485275#M8579</link>
    <description>&lt;P&gt;After many attempts, I took a weekend off to clear my mind and came up with the following&lt;/P&gt;

&lt;P&gt;1) Create a search that ends in a table that determines if the entire process is a Pass or a Fail. To ensure every scenario worked, I needed to include the following&lt;/P&gt;

&lt;P&gt;makeresults | eval record_count=null&lt;BR /&gt;
| fields - _time&lt;BR /&gt;
| append &lt;BR /&gt;
Search | eventstats count as record_count | eval PASSFAIL=if(record_count=1,"Succeeded","Failed") | table PASSFAIL&lt;/P&gt;

&lt;P&gt;2) append my original search to the results above&lt;/P&gt;

&lt;P&gt;3) add a Stats command that brings the results into one record, rather than 5 records&lt;/P&gt;

&lt;P&gt;| stats values(PASSFAIL) as Overall_Status, list(URL) as URL, list(Status) AS URL_Status, List(message) as URL_Message&lt;/P&gt;

&lt;P&gt;The result are 1 row, but with the results from the 5 records consolidated into the one row&lt;BR /&gt;
- I can pass the PASSFAIL value into the email&lt;BR /&gt;
- I can include an inline table showing all the details. &lt;/P&gt;

&lt;P&gt;I hope this helps others &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:18:02 GMT</pubDate>
    <dc:creator>KAC</dc:creator>
    <dc:date>2020-09-30T05:18:02Z</dc:date>
    <item>
      <title>Alert Email Subject Control</title>
      <link>https://community.splunk.com/t5/Alerting/Alert-Email-Subject-Control/m-p/485274#M8578</link>
      <description>&lt;P&gt;I am producing data like this in an alert that will throw an email, which is needed. I'm attempting to control the email Subject and Message. I need to make an adjustment though. If all of the statuses are "SUCCEEDED" then I need to show that in the Subject and in the message. However, if any of the status are something other than "SUCCEEDED" then I need the Subject and the message to show that. &lt;/P&gt;

&lt;P&gt;NOTE: There will always be 5 items; That part is working as needed. &lt;/P&gt;

&lt;P&gt;item    Status         Message&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;1          SUCCEEDED    Success Message&lt;BR /&gt;
2          SUCCEEDED    Success Message&lt;BR /&gt;
3          SUCCEEDED    Success Message&lt;BR /&gt;
4          FAILED           Failure Message&lt;BR /&gt;
5          SUCCEEDED    Success Message&lt;/P&gt;

&lt;P&gt;Approach creating the above&lt;/P&gt;

&lt;P&gt;| eval subject= if(status="Failure","FAILED","SUCCEEDED")&lt;BR /&gt;
| eval message= if(status="Failure","Failure Message","Success Message")&lt;BR /&gt;
| rename affected_ci as URL, subject as Status, event_date_time as Date&lt;BR /&gt;
| table item, status, message, &lt;/P&gt;

&lt;P&gt;What I'm needing is&lt;/P&gt;

&lt;P&gt;item    Status         Message                    Subject_Value   Email_Message&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;1          SUCCEEDED    Success Message    Failure                Failure Message&lt;BR /&gt;
2          SUCCEEDED    Success Message    Failure                Failure Message&lt;BR /&gt;
3          SUCCEEDED    Success Message    Failure                Failure Message&lt;BR /&gt;
4          FAILED           Failure Message      Failure                Failure Message&lt;BR /&gt;
5          SUCCEEDED    Success Message     Failure                Failure Message&lt;/P&gt;

&lt;P&gt;The idea here is, I need to pass the subject and email message into every row, then use the &lt;/P&gt;

&lt;P&gt;$result.Subject_Value$   and $result.Email_Message$ in the appropriate field.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:11:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alert-Email-Subject-Control/m-p/485274#M8578</guid>
      <dc:creator>KAC</dc:creator>
      <dc:date>2020-09-30T05:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Alert Email Subject Control</title>
      <link>https://community.splunk.com/t5/Alerting/Alert-Email-Subject-Control/m-p/485275#M8579</link>
      <description>&lt;P&gt;After many attempts, I took a weekend off to clear my mind and came up with the following&lt;/P&gt;

&lt;P&gt;1) Create a search that ends in a table that determines if the entire process is a Pass or a Fail. To ensure every scenario worked, I needed to include the following&lt;/P&gt;

&lt;P&gt;makeresults | eval record_count=null&lt;BR /&gt;
| fields - _time&lt;BR /&gt;
| append &lt;BR /&gt;
Search | eventstats count as record_count | eval PASSFAIL=if(record_count=1,"Succeeded","Failed") | table PASSFAIL&lt;/P&gt;

&lt;P&gt;2) append my original search to the results above&lt;/P&gt;

&lt;P&gt;3) add a Stats command that brings the results into one record, rather than 5 records&lt;/P&gt;

&lt;P&gt;| stats values(PASSFAIL) as Overall_Status, list(URL) as URL, list(Status) AS URL_Status, List(message) as URL_Message&lt;/P&gt;

&lt;P&gt;The result are 1 row, but with the results from the 5 records consolidated into the one row&lt;BR /&gt;
- I can pass the PASSFAIL value into the email&lt;BR /&gt;
- I can include an inline table showing all the details. &lt;/P&gt;

&lt;P&gt;I hope this helps others &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:18:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alert-Email-Subject-Control/m-p/485275#M8579</guid>
      <dc:creator>KAC</dc:creator>
      <dc:date>2020-09-30T05:18:02Z</dc:date>
    </item>
  </channel>
</rss>

