<?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: Creating a python script that forwards data to Splunk, what library and function can I use to make this? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121490#M1774</link>
    <description>&lt;P&gt;It means that you need create "test_index" inside splunk, before send into it&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 15:38:55 GMT</pubDate>
    <dc:creator>monserta</dc:creator>
    <dc:date>2017-09-19T15:38:55Z</dc:date>
    <item>
      <title>Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121472#M1756</link>
      <description>&lt;P&gt;Hi all, &lt;BR /&gt;
I would like to create a simple script in python that forwards a syslog file from ubtuntu VM to Splunk.&lt;BR /&gt;
My syslog files are stored in a folder in ubuntu\home, and when the script runs, it should take the file and forward it to splunk, installed on the same ubuntu VM.&lt;/P&gt;

&lt;P&gt;My question is: What library and what function can I use to make this?&lt;BR /&gt;
My big problem is that I can't install the splunk SDK for python. I have tried thousand of times, but I always have the same installation problems, so I would like to find if I can make this in another way.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:26:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121472#M1756</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-28T17:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121473#M1757</link>
      <description>&lt;P&gt;Why don't you use a Splunk Universal Forwarder to monitor the files and forward them to your Splunk Indexer ? Much more robust approach.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 10:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121473#M1757</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T10:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121474#M1758</link>
      <description>&lt;P&gt;I have installed it, but I have need to generate specific log and send them to my splunk.&lt;BR /&gt;
Like "generate 5  529 log and next 3 4020 log and so on..."&lt;BR /&gt;
In the end, I've found how install the python sdk, and I'm trying to send the data using "To add data directly to an index" but with this code: &lt;/P&gt;

&lt;P&gt;myindex = service.indexes["test_index"]&lt;/P&gt;

&lt;P&gt;uploadme = "/Applications/Splunk/README-splunk.txt"&lt;/P&gt;

&lt;P&gt;myindex.upload(name_file.txt);&lt;/P&gt;

&lt;P&gt;but it give me this error: " raise KeyError(key)&lt;BR /&gt;
KeyError: UrlEncoded('test_index') "&lt;/P&gt;

&lt;P&gt;I have not found so many documentations about these library...&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 11:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121474#M1758</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-29T11:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121475#M1759</link>
      <description>&lt;P&gt;You can not upload remote files to Splunk.&lt;BR /&gt;
The upload method takes the path of  a file that is already local to the Splunk instance.&lt;/P&gt;

&lt;P&gt;You will need to write python code to read in the contents of the files.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEE6#add2index"&gt;Then use the submit or attach methods&lt;/A&gt; to send the data to Splunk.&lt;/P&gt;

&lt;P&gt;Still better to use a Universal Forwarder(UF).&lt;/P&gt;

&lt;P&gt;1) you have some code , presumably a scheduled process , that periodically generates log files.&lt;BR /&gt;
2) you configure the UF the monitor the directory where you write these log files to&lt;/P&gt;

&lt;P&gt;Simple !&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 12:06:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121475#M1759</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T12:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121476#M1760</link>
      <description>&lt;P&gt;Thank you! Ok I can use the submit or the attach, I got it, but how I can  write python code to read in the contents of the files? I have xml file saved in my home. &lt;BR /&gt;
(syslog file write in xml) &lt;/P&gt;

&lt;P&gt;something like this: &lt;BR /&gt;
with file(filename) as f:&lt;BR /&gt;
    s = f.read() ?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 12:14:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121476#M1760</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-29T12:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121477#M1761</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client

service = client.connect(host='localhost',port=8089,username='admin',password='somepass')

myindex = service.indexes["main"]

mysocket = myindex.attach(sourcetype='myfile',host='myhost')

file_data = ''
with open("foo.txt", "r") as lines:
    for line in lines:
        if line.isspace():             
            line = ' '
        file_data += line      
        file_data += '\r\n'
    mysocket.send(file_data)
mysocket.close()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Jan 2015 13:03:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121477#M1761</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T13:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121478#M1762</link>
      <description>&lt;P&gt;Ok with both of them send data to splunk, but my data is not what I want. &lt;BR /&gt;
I send a xml file, but Splunk don't extract all the field, and don't read all the row... If for example this is my syslog stored in xml :&lt;/P&gt;

&lt;P&gt;*&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;4673 &lt;BR /&gt;
  0 &lt;BR /&gt;
  0 &lt;BR /&gt;
  13056 &lt;BR /&gt;
  0 &lt;BR /&gt;
  0x8010000000000000 &lt;/P&gt;

&lt;P&gt;232992271 &lt;/P&gt;

&lt;P&gt;Security &lt;BR /&gt;
  FROSSI-LT.integrity.local &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;S-1-5-21-1549169020-2314017464-2061785924-3556 &lt;BR /&gt;
FRossi &lt;BR /&gt;
INTEGDOM &lt;BR /&gt;
0x2235d &lt;BR /&gt;
Security &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;
SeCreateGlobalPrivilege 
0xd58 
C:\Program Files\Realtek\Audio\HDA\WavesSvc64.exe &lt;/LI&gt;
&lt;LI&gt; &lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;This is my event in splunk:&lt;/P&gt;

&lt;P&gt;*1/29/15             2:14:20.000 PM&lt;BR /&gt;&lt;BR /&gt;
-  -   4673 0 0 13056 0 0x8010000000000000&lt;/P&gt;

&lt;P&gt;Event Actions&lt;BR /&gt;
Type        Field   Value   Actions&lt;BR /&gt;
Selected        host    127.0.0.1&lt;BR /&gt;&lt;BR /&gt;
    source  http-stream&lt;BR /&gt;&lt;BR /&gt;
    sourcetype  http-stream-too_small&lt;BR /&gt;&lt;BR /&gt;
Event       Guid    {54849625-5478-4994-A5BA-3E3B0328C30D}&lt;BR /&gt;&lt;BR /&gt;
    Name    Microsoft-Windows-Security-Auditing&lt;BR /&gt;&lt;BR /&gt;
    index   main&lt;BR /&gt;&lt;BR /&gt;
    linecount   9&lt;BR /&gt;&lt;BR /&gt;
    splunk_server   ubuntu&lt;BR /&gt;&lt;BR /&gt;
    timestamp   none&lt;BR /&gt;&lt;BR /&gt;
    xmlns   &lt;A href="http://schemas.microsoft.com/win/2004/08/events/event" target="_blank"&gt;http://schemas.microsoft.com/win/2004/08/events/event&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;
Time        &lt;EM&gt;time   2015-01-29T14:14:20.000+00:00&lt;BR /&gt;&lt;BR /&gt;
Default         punct   -&lt;/EM&gt;&amp;lt;&lt;EM&gt;="://../////"&amp;gt;-&lt;/EM&gt;&amp;lt;&amp;gt;&lt;STRONG&gt;&amp;lt;&lt;EM&gt;="---"&lt;/EM&gt;="{----}"_/&amp;gt;&lt;/STRONG&gt;_&amp;lt;&amp;gt;  * &lt;/P&gt;

&lt;P&gt;Instead I would like have a events equals to a syslog file&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121478#M1762</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2020-09-28T18:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121479#M1763</link>
      <description>&lt;P&gt;My code I provided above works perfectly for me.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 14:44:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121479#M1763</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T14:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121480#M1764</link>
      <description>&lt;P&gt;And how is your file that send in splunk?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 16:21:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121480#M1764</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-29T16:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121481#M1765</link>
      <description>&lt;P&gt;Any text file. Have you actually tried the above code I posted yet ?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 16:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121481#M1765</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T16:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121482#M1766</link>
      <description>&lt;P&gt;Yeah, sure. &lt;BR /&gt;
But when I send the file, splunk don't extract all the field, but only a few, maybe 5 or 6.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 16:39:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121482#M1766</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-29T16:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121483#M1767</link>
      <description>&lt;P&gt;OK , so are you talking about data uploading or field extraction now ? I'm having a very hard time following you.&lt;/P&gt;

&lt;P&gt;If you are talking about field extraction , then the docs are a useful start : &lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Managesearch-timefieldextractions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Managesearch-timefieldextractions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 16:42:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121483#M1767</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T16:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121484#M1768</link>
      <description>&lt;P&gt;I'm very sorry!&lt;BR /&gt;
Yes, my file is in splunk, but it look like a long string, there are not all the field that there is normally when I use the splunk forwarder to send equal files..&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 16:46:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121484#M1768</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-29T16:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121485#M1769</link>
      <description>&lt;P&gt;Are you using the &lt;STRONG&gt;EXACT&lt;/STRONG&gt; code that I have posted above ?  Because I just tried it with multiple different text files , worked fine every time.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 16:53:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121485#M1769</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T16:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121486#M1770</link>
      <description>&lt;P&gt;yeah, the same exact code, I think that depends of the files...I think&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 17:04:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121486#M1770</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-01-29T17:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121487#M1771</link>
      <description>&lt;P&gt;email me your actual file.&lt;/P&gt;

&lt;P&gt;&lt;A href="mailto:ddallimore@splunk.com"&gt;ddallimore@splunk.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 17:05:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121487#M1771</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T17:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121488#M1772</link>
      <description>&lt;P&gt;Please email the &lt;STRONG&gt;actual file&lt;/STRONG&gt; .You emailed me a copy/paste of the file contents.&lt;/P&gt;

&lt;P&gt;Email attachments are your friend.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jan 2015 17:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121488#M1772</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-29T17:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121489#M1773</link>
      <description>&lt;P&gt;Using the example log file you emailed me (log5.txt) and using the exact same python code that I have provided for you above , the file contents are correctly sent to Splunk.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;File contents&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/205iEADD1860837403C9/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;File contents indexed in Splunk&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/206i3D2FCD5B67F38491/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Jan 2015 09:56:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121489#M1773</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-01-31T09:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a python script that forwards data to Splunk, what library and function can I use to make this?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121490#M1774</link>
      <description>&lt;P&gt;It means that you need create "test_index" inside splunk, before send into it&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 15:38:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Creating-a-python-script-that-forwards-data-to-Splunk-what/m-p/121490#M1774</guid>
      <dc:creator>monserta</dc:creator>
      <dc:date>2017-09-19T15:38:55Z</dc:date>
    </item>
  </channel>
</rss>

