<?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 Defining a global token for alert recipients in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694235#M19833</link>
    <description>&lt;P&gt;I have been trying to achieve "grouped email recipients" and while it is possible, it just won't behave the way I want with generative commands.&lt;/P&gt;&lt;P&gt;For "raw events" it works great to have a macro with an eval setting "recipients" to a list of email adresses and then using $result.recipients$ in the "action.email.to ="&lt;/P&gt;&lt;P&gt;Howerver, for things like stats and table, this does not work as the actual values of recipients are not part of the results.&lt;/P&gt;&lt;P&gt;So for "table" it works if I include "recipients" in the table, but that looks horrible. This can be sort of demonstrated like so where this works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="_internal" 
| `recipients` 
| dedup log_level 
| table log_level 
| fields recipients&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And this does not&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="_internal"
| eval recipients = "email1@email.com, email2@email.com"
| dedup log_level 
| table log_level
| fields recipients&lt;/LI-CODE&gt;&lt;P&gt;As recipients is empty&lt;/P&gt;&lt;P&gt;So, someone suggested that one could use a savedsearches.conf.spec file to define a token like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[savedsearches]
recipients = &amp;lt;string&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;and then use "recipients" in the savedsearches.conf file as $recipients$. This does not seem to be the case though, I cannot find this documented anywhere and the spec file seems to be more "instructive" than anything.&lt;/P&gt;&lt;P&gt;Another suggestion was to define global token directly in the savedsearhes file like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[tokens]
recipients = Comma-separated list of email addresses&lt;/LI-CODE&gt;&lt;P&gt;and then use $recipients$ for all "action.email.to = $recipients$" in that file. Though I cannot find the token definition solution here documented anywhere.&lt;/P&gt;&lt;P&gt;Are any of these suggestions at all valid? Is there any way to somewhere in the app where the alerts live to define a "token" like "recipients" which can be referenced in all "action.email.to" instances in that file so that I only have to update one list in one place?&lt;/P&gt;&lt;P&gt;Or is this a "suggested improvement" I need to submit somewhere &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 17:00:50 GMT</pubDate>
    <dc:creator>fatsug</dc:creator>
    <dc:date>2024-07-24T17:00:50Z</dc:date>
    <item>
      <title>Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694235#M19833</link>
      <description>&lt;P&gt;I have been trying to achieve "grouped email recipients" and while it is possible, it just won't behave the way I want with generative commands.&lt;/P&gt;&lt;P&gt;For "raw events" it works great to have a macro with an eval setting "recipients" to a list of email adresses and then using $result.recipients$ in the "action.email.to ="&lt;/P&gt;&lt;P&gt;Howerver, for things like stats and table, this does not work as the actual values of recipients are not part of the results.&lt;/P&gt;&lt;P&gt;So for "table" it works if I include "recipients" in the table, but that looks horrible. This can be sort of demonstrated like so where this works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="_internal" 
| `recipients` 
| dedup log_level 
| table log_level 
| fields recipients&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And this does not&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="_internal"
| eval recipients = "email1@email.com, email2@email.com"
| dedup log_level 
| table log_level
| fields recipients&lt;/LI-CODE&gt;&lt;P&gt;As recipients is empty&lt;/P&gt;&lt;P&gt;So, someone suggested that one could use a savedsearches.conf.spec file to define a token like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[savedsearches]
recipients = &amp;lt;string&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;and then use "recipients" in the savedsearches.conf file as $recipients$. This does not seem to be the case though, I cannot find this documented anywhere and the spec file seems to be more "instructive" than anything.&lt;/P&gt;&lt;P&gt;Another suggestion was to define global token directly in the savedsearhes file like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[tokens]
recipients = Comma-separated list of email addresses&lt;/LI-CODE&gt;&lt;P&gt;and then use $recipients$ for all "action.email.to = $recipients$" in that file. Though I cannot find the token definition solution here documented anywhere.&lt;/P&gt;&lt;P&gt;Are any of these suggestions at all valid? Is there any way to somewhere in the app where the alerts live to define a "token" like "recipients" which can be referenced in all "action.email.to" instances in that file so that I only have to update one list in one place?&lt;/P&gt;&lt;P&gt;Or is this a "suggested improvement" I need to submit somewhere &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 17:00:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694235#M19833</guid>
      <dc:creator>fatsug</dc:creator>
      <dc:date>2024-07-24T17:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694238#M19834</link>
      <description>&lt;P&gt;You can set recipients as a hidden field by prepending '_' to the field name. This will prevent the recipients column from appearing in the table, but the token will still work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _recipients = "email1@email.com, email2@email.com"&lt;/LI-CODE&gt;&lt;P&gt;Then use:&lt;/P&gt;&lt;P&gt;$result._recipients$ in the "action.email.to ="&lt;/P&gt;&lt;P&gt;I would also suggest putting this _recipients eval at the end of your search so it does not accidentally get removed by things like "table". It should also work if you put the eval statement into a macro.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 19:12:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694238#M19834</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2024-07-24T19:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694274#M19838</link>
      <description>&lt;P&gt;Sweet relief after so much trial and error, I could kiss you!&lt;/P&gt;&lt;P&gt;Yes, this solution finally works!&lt;/P&gt;&lt;P&gt;savedsearches.conf&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;basesearch&amp;gt;
| table &amp;lt;something&amp;gt;
| `macro`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;macro.conf&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[macro]
definition = eval _recipients="email1@email.com, email2@email.com"&lt;/LI-CODE&gt;&lt;P&gt;and finally in the savedsearches.conf (or To: field in the UI)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;action.email.to = $result._recipients$&lt;/LI-CODE&gt;&lt;P&gt;And it finnaly works as intended!!! &lt;span class="lia-unicode-emoji" title=":clapping_hands:"&gt;👏&lt;/span&gt;&amp;nbsp;&lt;SPAN&gt;Whish I could reward 100 karma for this &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Still think that this should be a "built in" thing available both in the GUI and config files, "email groups", but I'm to happy to care right now&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 08:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694274#M19838</guid>
      <dc:creator>fatsug</dc:creator>
      <dc:date>2024-07-25T08:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694672#M19860</link>
      <description>&lt;P&gt;This solution still works for most cases, however if you need an alert where number of events is 0 then this solution will not work, not "as is" at least.&lt;/P&gt;&lt;P&gt;As a search for, lets say a problem with logshipping, should alert on 0 returned events. Then there is no way to hitch on a hidden field to anything as there are no results.&lt;/P&gt;&lt;P&gt;So to fill "all my needs" here, I would have to come up with something completely different, it would need to become a feature in Splunk or I have to sort out an manage a number of group recipients in exchange.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 12:32:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694672#M19860</guid>
      <dc:creator>fatsug</dc:creator>
      <dc:date>2024-07-30T12:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694895#M19879</link>
      <description>&lt;P&gt;You can use the following segment to make the alert trigger even when its search returns zero events:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;yoursearch&amp;gt;
| appendpipe 
    [ stats count 
    | eval description="No problems found. All is well!" 
    | where count = 0 
    | fields - count]&lt;/LI-CODE&gt;&lt;P&gt;If there are results from the initial search, then this segment does not change the results. But if there are no results from the initial search, this segment will create a single row with a single field of "description" containing the string.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 19:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694895#M19879</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2024-07-31T19:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694915#M19883</link>
      <description>&lt;P&gt;Sweet&lt;/P&gt;&lt;P&gt;I re-wrote the "if 0 events" to "if there were events but now there are none"&lt;/P&gt;&lt;P&gt;This way I suppose the alert should be set to if there are "1 events"? If the initial search returns 0 events then there will be 1 generated event with the field "description".&lt;/P&gt;&lt;P&gt;Thanx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 21:38:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/694915#M19883</guid>
      <dc:creator>fatsug</dc:creator>
      <dc:date>2024-07-31T21:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/695017#M19890</link>
      <description>&lt;P&gt;Yes, if you add the segment in my last reply then your alert will always find at least one result.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 18:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/695017#M19890</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2024-08-01T18:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/695044#M19892</link>
      <description>&lt;P&gt;You know, sometimes you know something but until you really test all options you're just not sure.&lt;/P&gt;&lt;P&gt;WIth a "count", like&lt;/P&gt;&lt;PRE&gt;| tstats count WHERE index="&amp;lt;index&amp;gt;" earliest="-5min" latest=now()&lt;BR /&gt;| `&amp;lt;mail_macro&amp;gt;` &lt;BR /&gt;| rename count as "Events"&lt;/PRE&gt;&lt;P&gt;There will always be at least one result "0" (zero). It also does not matter if the count is 0 or 99999999, there is exactly 1 result. So the email macro does work, the condition "Number of results = 0" just fails, and it will fail producing false positives with "&amp;gt;=1" as well.&lt;/P&gt;&lt;P&gt;I forgot about "custom trigger conditions" though, which is likely the best solution for the intended usecase.&lt;/P&gt;&lt;PRE&gt;| tstats count WHERE index="&amp;lt;index&amp;gt;" earliest="-5min" latest=now()&lt;BR /&gt;| eval Information = if(count="0", "Currently f-d","Working")&lt;BR /&gt;| `&amp;lt;mail_macro&amp;gt;` &lt;BR /&gt;| rename count as "Events"&lt;/PRE&gt;&lt;P&gt;Then using a "custom trigger" like 'search Events = "Currently f-d"' works just as well as the solution outputing only results where there were events last x minutes but are zero events current x minutes.&lt;/P&gt;&lt;P&gt;Probably more effective as well.&lt;/P&gt;&lt;P&gt;Thank you both for your help, the community here is fantastic&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 06:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/695044#M19892</guid>
      <dc:creator>fatsug</dc:creator>
      <dc:date>2024-08-02T06:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a global token for alert recipients</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/745389#M22185</link>
      <description>&lt;P&gt;&lt;A href="https://ideas.splunk.com/ideas/EID-I-2368" target="_blank"&gt;"Email recipients groups" | Ideas&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 17:48:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Defining-a-global-token-for-alert-recipients/m-p/745389#M22185</guid>
      <dc:creator>fatsug</dc:creator>
      <dc:date>2025-05-02T17:48:09Z</dc:date>
    </item>
  </channel>
</rss>

