<?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: Custom Alert action shell script in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285797#M12014</link>
    <description>&lt;P&gt;Are you looking for the search results?&lt;/P&gt;

&lt;P&gt;If so there will be a file on a path specified by argument 8.  You must use your script to read this file and use it as the payload.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2017 11:26:29 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2017-03-01T11:26:29Z</dc:date>
    <item>
      <title>How to create Custom Alert action shell script?</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285794#M12011</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Currently I am creating a Custom Alert action script as per documentation &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.2/AdvancedDev/CustomAlertScript" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.2/AdvancedDev/CustomAlertScript&lt;/A&gt; but I would like to create Shell script instead of Python script.&lt;/P&gt;
&lt;P&gt;In shell script to fetch payload I am using &lt;CODE&gt;read sessionKey&lt;/CODE&gt; in shell script, is this correct way ?? Or Do I need to use some other code to fetch payload value in shell script?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Harshil&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 20:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285794#M12011</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2023-08-03T20:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285795#M12012</link>
      <description>&lt;P&gt;You'll need to read in the arguments via stdin.  &lt;/P&gt;

&lt;P&gt;Please see this link for just about everything you need and let us know if you get stuck:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Alert/Configuringscriptedalerts"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Alert/Configuringscriptedalerts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The downside to using a bash script as an alert action is that you only get those 7 arguments.  To read the results you have to read &amp;amp; manipulate the data file who's path is provided by the 8th argument.&lt;/P&gt;

&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 10:45:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285795#M12012</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-03-01T10:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285796#M12013</link>
      <description>&lt;P&gt;Currently in script I am using SPLUNK_ARG_1 ... 8 and that script I am using in "run a script alert action" &amp;amp; it is working fine but the feature is deprecated now.&lt;/P&gt;

&lt;P&gt;So I have new script based on "Custom Alert Action" but I can use only &lt;CODE&gt;read sessionKey&lt;/CODE&gt; as STDIN in Shell Script&lt;/P&gt;

&lt;P&gt;I am getting Payload via this script&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash
if [[ "$1" == "--execute" ]]; then
    read sessionKey
    echo $sessionKey &amp;gt; /tmp/payload_output.txt
fi
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But If I use other variables in script those are not working/no output.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash
if [[ "$1" == "--execute" ]]; then
    read SPLUNK_ARG_0
    echo $SPLUNK_ARG_0 &amp;gt; /tmp/payload_output.txt
    echo $SPLUNK_ARG_1 &amp;gt;&amp;gt;  /tmp/payload_output.txt
fi
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So my question is &lt;CODE&gt;read sessionKey&lt;/CODE&gt; which I am using in first script and I am getting payload value, so is this correct method to fetch payload value in Custom Alert Action script ?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285796#M12013</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2020-09-29T13:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285797#M12014</link>
      <description>&lt;P&gt;Are you looking for the search results?&lt;/P&gt;

&lt;P&gt;If so there will be a file on a path specified by argument 8.  You must use your script to read this file and use it as the payload.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 11:26:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285797#M12014</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-03-01T11:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285798#M12015</link>
      <description>&lt;P&gt;While using argument in script based on this &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.5/AdvancedDev/CustomAlertScript" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.5/AdvancedDev/CustomAlertScript&lt;/A&gt; , those arguments (SPLUNK_ARG_0 ... &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; are not working.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285798#M12015</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2020-09-29T13:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285799#M12016</link>
      <description>&lt;P&gt;Ok I understand your question now.  Yes you are doing it correctly except I wouldn't call the payload sessionKey I would call it payload:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; read payload
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Mar 2017 12:10:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285799#M12016</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-03-01T12:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285800#M12017</link>
      <description>&lt;P&gt;Perfect. working fine, Thanks. I am not able to convert your last comment as Answer, so accepting first answer as Answer.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 12:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285800#M12017</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-03-01T12:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285801#M12018</link>
      <description>&lt;P&gt;Hey you did see in alert_actions.conf where you can change the payload format to xml or JSON I hope!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 12:30:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285801#M12018</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-03-01T12:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285802#M12019</link>
      <description>&lt;P&gt;Yes, I already converted into JSON format in alert_actions.conf&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 12:32:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/285802#M12019</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-03-01T12:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Alert action shell script</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/653107#M15243</link>
      <description>&lt;P&gt;I realize this is a dated post but is closely aligned with the issue I am having with my shell script custom alert action.. Please elaborate on how you read in the stdin arguments to the shell script. I copied the sample script in the docs. The alert triggers the script and will print the $0 but the rest of the variables are null. Do I need to list the SPLUNK_ARG_x variables out in the alert_actions.conf?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 19:58:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-create-Custom-Alert-action-shell-script/m-p/653107#M15243</guid>
      <dc:creator>splunkettes</dc:creator>
      <dc:date>2023-08-03T19:58:15Z</dc:date>
    </item>
  </channel>
</rss>

