<?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: How to create pre-actions to a custom StreamingCommand with SDK v2? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440133#M7984</link>
    <description>&lt;P&gt;I’ve built everything using intersplunk.py so far.  I don’t have much experience with v2 of the search sdk.  I will say I think you have to have chunked=true in commands.conf for v2 commands.  Not sure what else could cause it from a settings stand point.&lt;/P&gt;

&lt;P&gt;Might have to share your code so we can help more.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Feb 2019 02:17:53 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2019-02-01T02:17:53Z</dc:date>
    <item>
      <title>How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440127#M7978</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to build a new custom StreamingCommand with SDK v2.&lt;/P&gt;

&lt;P&gt;I would like this command to create a unique folder when it starts. The folder name is randomly generated with python.&lt;BR /&gt;
The issue is that the streaming command calls these few lines of code (where I create a random folder) several times along the time the command run.&lt;BR /&gt;
This means that instead of having just one folder, the command can create hundred of folder if the command run for a long time...&lt;/P&gt;

&lt;P&gt;I think it is the normal behavior of a streaming command where it is called on a set of events. But is there a way to run some part of the code just once, at the beginning of the search job?&lt;/P&gt;

&lt;P&gt;I tried to place my code outside of the &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;def stream(self, records):
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and right before :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dispatch(MyCommand, sys.argv, sys.stdin, sys.stdout, __name__)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it is not changing anything.&lt;/P&gt;

&lt;P&gt;Any idea?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 10:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440127#M7978</guid>
      <dc:creator>davietch</dc:creator>
      <dc:date>2019-01-31T10:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440128#M7979</link>
      <description>&lt;P&gt;You need to change your command to not allow it to run in preview.  There’s a setting in commands.conf to disable preview for the spl command.&lt;/P&gt;

&lt;P&gt;With preview on, chunks of data go through your command as they arrive causing your code to execute multiple times.  With preview off, your command only executes once.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 12:36:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440128#M7979</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-01-31T12:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440129#M7980</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;run_in_preview = [true|false]
* Specify whether to run this command if generating results just for preview
  rather than final output.
* Defaults to true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 12:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440129#M7980</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-01-31T12:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440130#M7981</link>
      <description>&lt;P&gt;Hi Jkat,&lt;/P&gt;

&lt;P&gt;Thank you but I already disabled it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;run_in_preview = false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Actually, this solved one issue:&lt;BR /&gt;
When running a "stats count by X", and then applied my custom command, I was received the preview data. Turning this setting to false forced Splunk to give me the final result for each X field.&lt;BR /&gt;
The problem is that it does not block Splunk from running several times the "stream" function...&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 12:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440130#M7981</guid>
      <dc:creator>davietch</dc:creator>
      <dc:date>2019-01-31T12:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440131#M7982</link>
      <description>&lt;P&gt;Can you share your commands.conf?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 12:56:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440131#M7982</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-01-31T12:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440132#M7983</link>
      <description>&lt;P&gt;Sure:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[savetofile]
filename = savetofile.py
enableheader = true
outputheader = true
requires_srinfo = true
stderr_dest = message
supports_getinfo = true
supports_rawargs = true
supports_multivalues = true
run_in_preview = false
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 13:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440132#M7983</guid>
      <dc:creator>davietch</dc:creator>
      <dc:date>2019-01-31T13:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create pre-actions to a custom StreamingCommand with SDK v2?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440133#M7984</link>
      <description>&lt;P&gt;I’ve built everything using intersplunk.py so far.  I don’t have much experience with v2 of the search sdk.  I will say I think you have to have chunked=true in commands.conf for v2 commands.  Not sure what else could cause it from a settings stand point.&lt;/P&gt;

&lt;P&gt;Might have to share your code so we can help more.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 02:17:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-create-pre-actions-to-a-custom-StreamingCommand-with-SDK/m-p/440133#M7984</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-02-01T02:17:53Z</dc:date>
    </item>
  </channel>
</rss>

