<?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: Can you put a non-tabled field in an alert title? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476949#M133894</link>
    <description>&lt;P&gt;I changed the field name to &lt;CODE&gt;mysubject&lt;/CODE&gt; - both in the SPL and in the alert subject - with the same result.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jan 2020 21:02:10 GMT</pubDate>
    <dc:creator>nick405060</dc:creator>
    <dc:date>2020-01-08T21:02:10Z</dc:date>
    <item>
      <title>Can you put a non-tabled field in an alert title?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476947#M133892</link>
      <description>&lt;P&gt;I want to be able to put a token in my alert title that is derived from a field NOT in the displayed results table.&lt;/P&gt;

&lt;P&gt;How? The below does not work:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults | eval a="junk" | eval b="junk" | eval _a=a | table b&lt;/CODE&gt; + &lt;CODE&gt;Splunk Alert: $name$ $result._a$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 20:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476947#M133892</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2020-01-08T20:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can you put a non-tabled field in an alert title?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476948#M133893</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;eval _subject=subject &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;underbar field is unvisible.&lt;BR /&gt;
you should change field name.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;action.email.subject.alert = Splunk Alert: $name$ ($result._subject$)&lt;/CODE&gt;&lt;BR /&gt;
don't forget this ,too.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 20:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476948#M133893</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-08T20:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can you put a non-tabled field in an alert title?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476949#M133894</link>
      <description>&lt;P&gt;I changed the field name to &lt;CODE&gt;mysubject&lt;/CODE&gt; - both in the SPL and in the alert subject - with the same result.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 21:02:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476949#M133894</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2020-01-08T21:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can you put a non-tabled field in an alert title?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476950#M133895</link>
      <description>&lt;P&gt;99% sure this is a bug. It seems the &lt;CODE&gt;table&lt;/CODE&gt;, &lt;CODE&gt;fields&lt;/CODE&gt;, and &lt;CODE&gt;stats&lt;/CODE&gt; commands breaks the tokenization of hidden fields. Per the below, and per other users I have talked to on 7.3, this issue exists from at least version 7.0 forwards.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/342128/why-does-resultfieldname-token-not-work-in-alert-e.html"&gt;https://answers.splunk.com/answers/342128/why-does-resultfieldname-token-not-work-in-alert-e.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;@the_tick mentioned maybe using field aliases to workaround, or &lt;CODE&gt;sendalert&lt;/CODE&gt;. I haven't tried either of those workarounds yet, but this was my solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval a="mysubject" | eval b="mycontent" | map maxsearches=10000 search="| makeresults | eval b=\"$b$\" | table b | sendemail server=smtp.gadsden.com to=\"myemail@gadsden.com\" subject=\"$a$\" message=\"Results:\" sendresults=true inline=true"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To adapt this template to your search, simply calculate the fields that you'll want to tokenize, before the map, and dedup to only be one row of data (e.g. you probably won't be using &lt;CODE&gt;makeresults&lt;/CODE&gt;). Next, in the map, write your actual alert and in &lt;CODE&gt;sendemail&lt;/CODE&gt; you can now use the calculated tokens from before the map.&lt;/P&gt;

&lt;P&gt;This is a sanitized example of my query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wineventlog (EventCode=4771 OR EventCode=4776 AND Keywords="Audit Failure") user=amkfk NOT Source_Workstation="TABLET3849" NOT Source_Workstation="TOKYO_OFFICE" NOT Source_Workstation="MKK_SURFPRO7"| rex field=_raw "Error Code:\s+(?&amp;lt;error_code&amp;gt;\S+)" | stats values(error_code) AS error_codes | eval error_codes=mvjoin(error_codes,",") | table error_codes |
map maxsearches=10000 search="search index=wineventlog (EventCode=4771 OR EventCode=4776 AND Keywords=\"Audit Failure\") user=amkfk NOT Source_Workstation=\"TABLET3849\" NOT Source_Workstation=\"TOKYO_OFFICE\" NOT Source_Workstation=\"MKK_SURFPRO7\" | rex field=_raw \"Error Code:\s+(?&amp;lt;error_code&amp;gt;\S+)\" | sort 0 _time | table _time user EventCode Source_Workstation ComputerName Keywords error_code | sendemail server=smtp.mydomain.com to=\"myemail@mydomain.com\" subject=\"Splunk Alert: amkfk_4771_4776 ($error_codes$)\" message=\"Results:\" sendresults=true inline=true"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 21:24:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-put-a-non-tabled-field-in-an-alert-title/m-p/476950#M133895</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2020-01-08T21:24:02Z</dc:date>
    </item>
  </channel>
</rss>

