<?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: Uploading files with python-sdk in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419026#M7326</link>
    <description>&lt;P&gt;Thank you for the answer but my events are in a file and that's why I'm trying to use a method for file upload.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2019 20:16:10 GMT</pubDate>
    <dc:creator>haktor5</dc:creator>
    <dc:date>2019-04-17T20:16:10Z</dc:date>
    <item>
      <title>Having trouble uploading log files with python-sdk - no errors, but don't see logs on indexes?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419024#M7324</link>
      <description>&lt;P&gt;I am working on a python script to upload logs to an index on the local Splunk server. I use splunk-sdk for python for this.&lt;/P&gt;
&lt;P&gt;Connection and some splunk-sdk example runs fine but I am having trouble when uploading logs.&lt;/P&gt;
&lt;P&gt;When i run the upload.py script with the file to be uploaded command runs with no error but I don't see the logs on any index. So far I tried:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;1. using the example script on github python-sdk page
2. implementing upload() method with indexes class described here: &lt;A href="https://docs.splunk.com/DocumentationStatic/PythonSDK/1.6.5/client.html#splunklib.client.Index.upload" target="test_blank"&gt;https://docs.splunk.com/DocumentationStatic/PythonSDK/1.6.5/client.html#splunklib.client.Index.upload&lt;/A&gt;
3. Implementing oneshot() method with inputs class
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;None of the above worked.&lt;/P&gt;
&lt;P&gt;What am i doing wrong? Is there any way to have some feedback on why the file wasn't uploaded?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEE6#createinput" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEE6#createinput&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEE6" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEE6&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEFK#upload" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEFK#upload&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 18:15:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419024#M7324</guid>
      <dc:creator>haktor5</dc:creator>
      <dc:date>2020-06-18T18:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading files with python-sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419025#M7325</link>
      <description>&lt;P&gt;You would be much better off sending the logs in via HTTP Event Collector (HEC) if you are already operating in python.  Read the file, blow in the events.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://dev.splunk.com/view/event-collector/SP-CAAAE6M"&gt;http://dev.splunk.com/view/event-collector/SP-CAAAE6M&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 20:03:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419025#M7325</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2019-04-17T20:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading files with python-sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419026#M7326</link>
      <description>&lt;P&gt;Thank you for the answer but my events are in a file and that's why I'm trying to use a method for file upload.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 20:16:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419026#M7326</guid>
      <dc:creator>haktor5</dc:creator>
      <dc:date>2019-04-17T20:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading files with python-sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419027#M7327</link>
      <description>&lt;P&gt;Not sure why it doesn't work. I use python to upload data from a file to an index on my local Splunk. This is what I did&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;1.&lt;/STRONG&gt; I installed splunk-sdk for python. Installed simply using the pip install command so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;pip install splunk-sdk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt; On python, you need to first connect to your local Splunk server&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"""Connect to splunk local"""

import splunklib.client as client
import splunklib.results as results
from splunklib.binding import AuthenticationError

HOST=localhost
PORT = '8089'
USERNAME = 'username'
PASSWORD = 'password'

try:
    service = client.connect(host=HOST, port=PORT, username=USERNAME, password=PASSWORD)
except exception as e:
    print(str(e))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt; Upload your file to your index&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myindex = service.indexes[ENTER INDEX NAME]  # Retrieve the index for the data

try:
    myindex.upload(ENTER THE ABSOLUTE PATH TO YOUR FILE)  # Upload file 
    to the index specified
except Exception as e:
    print(str(e))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 May 2019 06:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Having-trouble-uploading-log-files-with-python-sdk-no-errors-but/m-p/419027#M7327</guid>
      <dc:creator>vkannampuzha</dc:creator>
      <dc:date>2019-05-13T06:12:28Z</dc:date>
    </item>
  </channel>
</rss>

