<?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 Custom script input - How to let Splunk handle files through a custom script that will stream converted data to be indexed in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192127#M38289</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I'm currently working on an application that handles files with a very specific format Splunk cannot directly manage, data has to be converted through a third party script. (currently a perl script)&lt;/P&gt;

&lt;P&gt;I would like to adapt the current configuration to let Splunk handle files (based on pattern) and call the 3rd party script which gets the file name as argument.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;To sum up, my goal is:&lt;/STRONG&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Splunk watches for any new or updated file (as for any standard files input)&lt;/LI&gt;
&lt;LI&gt;when a new file is available or a CRC file differs, Splunk calls the third party script with the file name as argument&lt;/LI&gt;
&lt;LI&gt;The third party script streams the converted data that Splunk will index&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I already have a functional third party script that does that job but could yet find the better to proceed as required&lt;/P&gt;

&lt;P&gt;Thanks in advance for any help&lt;/P&gt;</description>
    <pubDate>Tue, 18 Mar 2014 09:18:14 GMT</pubDate>
    <dc:creator>guilmxm</dc:creator>
    <dc:date>2014-03-18T09:18:14Z</dc:date>
    <item>
      <title>Custom script input - How to let Splunk handle files through a custom script that will stream converted data to be indexed</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192127#M38289</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I'm currently working on an application that handles files with a very specific format Splunk cannot directly manage, data has to be converted through a third party script. (currently a perl script)&lt;/P&gt;

&lt;P&gt;I would like to adapt the current configuration to let Splunk handle files (based on pattern) and call the 3rd party script which gets the file name as argument.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;To sum up, my goal is:&lt;/STRONG&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Splunk watches for any new or updated file (as for any standard files input)&lt;/LI&gt;
&lt;LI&gt;when a new file is available or a CRC file differs, Splunk calls the third party script with the file name as argument&lt;/LI&gt;
&lt;LI&gt;The third party script streams the converted data that Splunk will index&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I already have a functional third party script that does that job but could yet find the better to proceed as required&lt;/P&gt;

&lt;P&gt;Thanks in advance for any help&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 09:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192127#M38289</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2014-03-18T09:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Custom script input - How to let Splunk handle files through a custom script that will stream converted data to be indexed</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192128#M38290</link>
      <description>&lt;P&gt;Did you look into using "unarchive_cmd" for this? It sounds like it could solve your situation, even though you're not strictly "unarchiving" anything, but the principle should still be the same - Splunk detects a change, invokes the script, then ingests the data that the script outputs.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/admin/Propsconf"&gt;http://docs.splunk.com/Documentation/Splunk/latest/admin/Propsconf&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;unarchive_cmd = &amp;lt;string&amp;gt;
* Only called if invalid_cause is set to "archive".
* This field is only valid on [source::&amp;lt;source&amp;gt;] stanzas.
* &amp;lt;string&amp;gt; specifies the shell command to run to extract an archived source.
* Must be a shell command that takes input on stdin and produces output on stdout.
* Use _auto for Splunk's automatic handling of archive files (tar, tar.gz, tgz, tbz, tbz2, zip)
* Defaults to empty.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Mar 2014 09:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192128#M38290</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-03-18T09:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Custom script input - How to let Splunk handle files through a custom script that will stream converted data to be indexed</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192129#M38291</link>
      <description>&lt;P&gt;Nice idea, i'll check and let you know, thanks&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 10:49:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192129#M38291</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2014-03-18T10:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Custom script input - How to let Splunk handle files through a custom script that will stream converted data to be indexed</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192130#M38292</link>
      <description>&lt;P&gt;Ayn,&lt;/P&gt;

&lt;P&gt;Thank you very much for your clever suggestion, this indeed did the job as i need &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 19:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192130#M38292</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2014-03-19T19:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Custom script input - How to let Splunk handle files through a custom script that will stream converted data to be indexed</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192131#M38293</link>
      <description>&lt;P&gt;For those who would be intesrested in such as case, here is how i got it to work as i need.&lt;/P&gt;

&lt;P&gt;As few links that helped to implement a 3rd party script with the unarchive_cmd stanza:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/7729/how-to-invoke-unarchive_cmd" target="_blank"&gt;http://answers.splunk.com/answers/7729/how-to-invoke-unarchive_cmd&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://blogs.splunk.com/2011/07/19/the-naughty-bits-how-to-splunk-binary-logfiles/" target="_blank"&gt;http://blogs.splunk.com/2011/07/19/the-naughty-bits-how-to-splunk-binary-logfiles/&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/10501/python-script-as-unarchive_cmd-in-propsconf" target="_blank"&gt;http://answers.splunk.com/answers/10501/python-script-as-unarchive_cmd-in-propsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also i had to adapt my 3rd party script to be able to manage data from stdin instead of the filename as argument (eg. cat &lt;MYFILE&gt; | myscript)&lt;BR /&gt;
Depending on your case and script, you may want your script to stream the converted data that will be directly indexed by Splunk (the simplest) or you may need your script to generate csv file(s) that would be indexed by Splunk. (my case)&lt;/MYFILE&gt;&lt;/P&gt;

&lt;P&gt;The configuration that worked as i need:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;You need to declare a source stanza associated to your 3rd party script:&lt;/P&gt;

&lt;P&gt;[source::/pathtorawfiles/*.&lt;MYFILEEXTENSION&gt;]&lt;BR /&gt;
invalid_cause = archive&lt;BR /&gt;
unarchive_cmd = &lt;FULLPATHTO3RDPARTYSCRIPT&gt;&lt;BR /&gt;
sourcetype = mysourcetype&lt;BR /&gt;
NO_BINARY_CHECK = true&lt;/FULLPATHTO3RDPARTYSCRIPT&gt;&lt;/MYFILEEXTENSION&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;In my case, my script generates several csv files (standard csv files with header) that Splunk will index, so i declared a second stanza. (you don't need this if your script outputs the data directly)&lt;/P&gt;

&lt;P&gt;[mydatasourcetype]&lt;/P&gt;

&lt;P&gt;FIELD_DELIMITER=,&lt;BR /&gt;
FIELD_QUOTE="&lt;BR /&gt;
HEADER_FIELD_LINE_NUMBER=1&lt;BR /&gt;
NO_BINARY_CHECK=1&lt;BR /&gt;
INDEXED_EXTRACTIONS=csv&lt;BR /&gt;
KV_MODE=none&lt;BR /&gt;
SHOULD_LINEMERGE=false&lt;BR /&gt;
pulldown_type=true&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;STRONG&gt;inputs.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;I declare a monitor associated to the raw data that need to be converted through my 3rd party script:&lt;/P&gt;

&lt;P&gt;[monitor:///pathtorawfiles/*.&lt;MYFILEEXTENSION&gt;]&lt;BR /&gt;
disabled = false&lt;BR /&gt;
index = myindex&lt;BR /&gt;
sourcetype = mysourcetype&lt;/MYFILEEXTENSION&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;As i my script generates csv files, i just want to index and delete them automatically:&lt;/P&gt;

&lt;P&gt;[batch://&lt;PATHTOCONVERTEDCSVFILES&gt;/*.csv]&lt;BR /&gt;
disabled = false&lt;BR /&gt;
move_policy = sinkhole&lt;BR /&gt;
recursive = false&lt;BR /&gt;
index = myindex&lt;BR /&gt;
sourcetype = mydatasourcetype&lt;/PATHTOCONVERTEDCSVFILES&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;And that's it, works like a charm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;This off course has to adapted to your requirement.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:11:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Custom-script-input-How-to-let-Splunk-handle-files-through-a/m-p/192131#M38293</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2020-09-28T16:11:06Z</dc:date>
    </item>
  </channel>
</rss>

