<?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: Piping in Splunk in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21328#M231</link>
    <description>&lt;P&gt;It sounds to me like you really want a custom search command, instead of doing what you described. See here &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Developer/SearchScripts"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Developer/SearchScripts&lt;/A&gt; and any of the *.py files in $SPLUNK_HOME/etc/apps/search/bin/ for examples and the docs for the commands.conf file. But basically, each of these is called as if it's a search command in the Splunk search pipeline, receives CSV (prefixed with a few lines of header) on stdin, and is expected to produce CSV on stdout. Splunk handles moving the CSV between each part of the search query pipeline.&lt;/P&gt;

&lt;P&gt;In the examples, you'll see a references to Intersplunk objects, and you can use it, or else you can ignore it and just read and process the CSV from stdin in your script.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jul 2012 20:45:09 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2012-07-30T20:45:09Z</dc:date>
    <item>
      <title>Piping in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21326#M229</link>
      <description>&lt;P&gt;Hi all:&lt;/P&gt;

&lt;P&gt;It is possible to pipe the results of a temp csv file created in search (using outputcsv) &amp;gt; into a python script located at $SPLUNK_HOME/etc/apps/search/bin &amp;gt; and then pipe it back into Splunk ? &lt;/P&gt;

&lt;P&gt;Note that the CSV file itself is an argument to the python script. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;with open('data.csv', 'rb') as f:
   reader = csv.reader(f)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So basically:&lt;BR /&gt;
&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;i) I want to take a search like this :  &lt;CODE&gt;sourcetype="access_combined" host="us-1" | outputcscv data.csv&lt;/CODE&gt;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
ii) Then take the data.csv and pass it to a python script (not sure how to go about it)&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
iii) Then take the output of the python script (which looks like this) - and put it back in Splunk&lt;/P&gt;

&lt;P&gt;ORG PROFIT%&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
1      10&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
2       5&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
5       7&lt;/P&gt;

&lt;P&gt;Any suggestions would be appreciated&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 17:53:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21326#M229</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2012-07-30T17:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Piping in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21327#M230</link>
      <description>&lt;P&gt;I think you can get close to what you want to do:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;You can configure a script to run when an alert or scheduled search is run. This can be the python script that you want to initiate. Splunk supports using the results a search in the script itself with the &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.3/admin/ConfigureScriptedAlerts" target="_blank"&gt;SPLUNK_ARG_8&lt;/A&gt; option. This is a gzip'd file that you have to read and put into a dictionary to use.&lt;/LI&gt;
&lt;LI&gt;Once your script is done doing it's thing you  can then write the results back to Splunk by dropping a file into the sinkhole directory (/opt/splunk/var/spool) so that they get splunk'd again and are available for searching.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:10:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21327#M230</guid>
      <dc:creator>Kate_Lawrence-G</dc:creator>
      <dc:date>2020-09-28T12:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Piping in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21328#M231</link>
      <description>&lt;P&gt;It sounds to me like you really want a custom search command, instead of doing what you described. See here &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Developer/SearchScripts"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Developer/SearchScripts&lt;/A&gt; and any of the *.py files in $SPLUNK_HOME/etc/apps/search/bin/ for examples and the docs for the commands.conf file. But basically, each of these is called as if it's a search command in the Splunk search pipeline, receives CSV (prefixed with a few lines of header) on stdin, and is expected to produce CSV on stdout. Splunk handles moving the CSV between each part of the search query pipeline.&lt;/P&gt;

&lt;P&gt;In the examples, you'll see a references to Intersplunk objects, and you can use it, or else you can ignore it and just read and process the CSV from stdin in your script.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 20:45:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Piping-in-Splunk/m-p/21328#M231</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-07-30T20:45:09Z</dc:date>
    </item>
  </channel>
</rss>

