<?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: Get environment variables in alert action script? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368738#M108701</link>
    <description>&lt;P&gt;Well, after some experimentation and staring at the rest command page as well as the sendalert page, I think I have a solution:&lt;/P&gt;

&lt;P&gt;In my alert_actions.conf, I put the following command(used a generic alert action name):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;command=join [ | rest splunk_server=local /services/authentication/current-context| rename username as auth_user_id | fields auth_user_id ] | &amp;lt;alert action name here&amp;gt; param.user_select=$result.auth_user_id$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It basically joins a rest call of the local context user to the search alert as auth_user_id, then pipes to sendalert, adding the auth_user_id to a param.  Seems to work so far....&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 17:01:46 GMT</pubDate>
    <dc:creator>jef152</dc:creator>
    <dc:date>2020-09-29T17:01:46Z</dc:date>
    <item>
      <title>Get environment variables in alert action script?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368735#M108698</link>
      <description>&lt;P&gt;How do I get the environment variables, for example $env:user$ into my alert action script?  I've tried adding a parameter to my alert_actions.conf (param.envuser=$env:user$) but that just shows up as the literal $env:user$ in my script, not the logged in user.  Any ideas?&lt;/P&gt;

&lt;P&gt;Any tips or hints appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Jon&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 19:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368735#M108698</guid>
      <dc:creator>jef152</dc:creator>
      <dc:date>2017-11-13T19:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get environment variables in alert action script?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368736#M108699</link>
      <description>&lt;P&gt;By user do you mean the owner of the alert?&lt;/P&gt;

&lt;P&gt;Do you mean $owner$ as documented in &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.0/Alert/EmailNotificationTokens"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.0/Alert/EmailNotificationTokens&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 23:12:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368736#M108699</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2017-11-13T23:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get environment variables in alert action script?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368737#M108700</link>
      <description>&lt;P&gt;No, not the owner of the alert.  For example, if a user is looking at an alert in Incident Review in ES and uses the 'Run Adaptive Response' to run my script on an alert, I want the script to capture that logged in user(I believe this is the $env:user$) that ran the script, not necessarily the owner of the alert.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 20:38:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368737#M108700</guid>
      <dc:creator>jef152</dc:creator>
      <dc:date>2017-11-14T20:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get environment variables in alert action script?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368738#M108701</link>
      <description>&lt;P&gt;Well, after some experimentation and staring at the rest command page as well as the sendalert page, I think I have a solution:&lt;/P&gt;

&lt;P&gt;In my alert_actions.conf, I put the following command(used a generic alert action name):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;command=join [ | rest splunk_server=local /services/authentication/current-context| rename username as auth_user_id | fields auth_user_id ] | &amp;lt;alert action name here&amp;gt; param.user_select=$result.auth_user_id$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It basically joins a rest call of the local context user to the search alert as auth_user_id, then pipes to sendalert, adding the auth_user_id to a param.  Seems to work so far....&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:01:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368738#M108701</guid>
      <dc:creator>jef152</dc:creator>
      <dc:date>2020-09-29T17:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get environment variables in alert action script?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368739#M108702</link>
      <description>&lt;P&gt;I'll post this as an official answer after having done some more testing.  It does seem to work well.&lt;/P&gt;

&lt;P&gt;In my alert_actions.conf, I put the following command(used a generic alert action name):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; command=join [ | rest splunk_server=local /services/authentication/current-context| rename username as auth_user_id | fields auth_user_id ] | &amp;lt;alert action name here&amp;gt; param.user_select=$result.auth_user_id$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 19:49:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-environment-variables-in-alert-action-script/m-p/368739#M108702</guid>
      <dc:creator>jef152</dc:creator>
      <dc:date>2017-12-06T19:49:31Z</dc:date>
    </item>
  </channel>
</rss>

