<?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: Why python file executes successfully to add data to an index through Splunk Python SDK, but no events are found in the index? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163988#M2190</link>
    <description>&lt;P&gt;The problem is about ": : : ". How to fix it????&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jul 2018 08:18:09 GMT</pubDate>
    <dc:creator>kairat</dc:creator>
    <dc:date>2018-07-09T08:18:09Z</dc:date>
    <item>
      <title>Why python file executes successfully to add data to an index through Splunk Python SDK, but no events are found in the index?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163985#M2187</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Im trying to add data to the index through Splunk Python SDK . Here .py  file is executed successfully but no events found inside the index&lt;BR /&gt;
Here are my code&lt;BR /&gt;
import splunklib.client as client&lt;BR /&gt;
import sys,os&lt;BR /&gt;
import socket&lt;BR /&gt;
............................&lt;/P&gt;

&lt;H1&gt;Create a Service instance and log in&lt;/H1&gt;

&lt;P&gt;service = client.connect(&lt;BR /&gt;
    host=HOST,&lt;BR /&gt;
    port=PORT,&lt;BR /&gt;
    username=USERNAME,&lt;BR /&gt;
    password=PASSWORD,&lt;BR /&gt;
    owner=OWNER,&lt;BR /&gt;
    app=APP)&lt;/P&gt;

&lt;H1&gt;Retrieve the index for the data&lt;/H1&gt;

&lt;H1&gt;myindex = service.indexes["test_index"]&lt;/H1&gt;

&lt;P&gt;myindex = service.indexes.create("test_index2")&lt;/P&gt;

&lt;H1&gt;with myindex.attached_socket(sourcetype='test') as sock:&lt;/H1&gt;

&lt;PRE&gt;&lt;CODE&gt;#sock.send("Test event\r\n")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H1&gt;sock.close()&lt;/H1&gt;

&lt;H1&gt;Open a socket&lt;/H1&gt;

&lt;P&gt;mysocket = myindex.attach()&lt;/P&gt;

&lt;H1&gt;Send events to it&lt;/H1&gt;

&lt;P&gt;mysocket.send("This is my socket event\r\n")&lt;/P&gt;

&lt;H1&gt;Close the socket&lt;/H1&gt;

&lt;P&gt;mysocket.close()&lt;/P&gt;

&lt;H2&gt;print "everything done"&lt;/H2&gt;

&lt;P&gt;Code Type 2 :&lt;BR /&gt;
import splunklib.client as client&lt;BR /&gt;
import sys,os&lt;BR /&gt;
.................................&lt;/P&gt;

&lt;H1&gt;Create a Service instance and log in&lt;/H1&gt;

&lt;P&gt;service = client.connect(&lt;BR /&gt;
  host=HOST,&lt;BR /&gt;
    port=PORT,&lt;BR /&gt;
    username=USERNAME,&lt;BR /&gt;
    password=PASSWORD,&lt;BR /&gt;
    owner=OWNER,&lt;BR /&gt;
    app=APP)&lt;/P&gt;

&lt;H1&gt;Retrieve the index for the data&lt;/H1&gt;

&lt;H1&gt;myindex = service.indexes["test_index"]&lt;/H1&gt;

&lt;H1&gt;Submit an event over HTTP&lt;/H1&gt;

&lt;P&gt;myindex.submit('This is my HTTP event',sourcetype='test', host='localhost')&lt;BR /&gt;
Please verify and let me know what changes i have to do?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 12:09:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163985#M2187</guid>
      <dc:creator>Bhuavana</dc:creator>
      <dc:date>2014-12-23T12:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why python file executes successfully to add data to an index through Splunk Python SDK, but no events are found in the index?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163986#M2188</link>
      <description>&lt;P&gt;just checked without owner=OWNER,,app=APP . below code worked&lt;/P&gt;

&lt;P&gt;service = client.connect(&lt;BR /&gt;
host=HOST,&lt;BR /&gt;
port=PORT,&lt;BR /&gt;
username=USERNAME,&lt;BR /&gt;
password=PASSWORD)&lt;/P&gt;

&lt;H1&gt;Retrieve the index for the data&lt;/H1&gt;

&lt;H1&gt;myindex = service.indexes["test_index"]&lt;/H1&gt;

&lt;H1&gt;Submit an event over HTTP&lt;/H1&gt;

&lt;P&gt;myindex.submit('This is my HTTP event',sourcetype='test', host='localhost')&lt;/P&gt;

&lt;P&gt;need to investigate it...&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 16:48:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163986#M2188</guid>
      <dc:creator>kml_uvce</dc:creator>
      <dc:date>2014-12-23T16:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why python file executes successfully to add data to an index through Splunk Python SDK, but no events are found in the index?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163987#M2189</link>
      <description>&lt;P&gt;How about if there is long string, such as "37.31.31.31 - - [13/Dec/2015:23:08:40 +0100] ""POST /administrator/index.php HTTP/1.1"" 200 4494 """ ""Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0"" ""-""" Somehow it ignores it...&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 05:53:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163987#M2189</guid>
      <dc:creator>kairat</dc:creator>
      <dc:date>2018-07-09T05:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why python file executes successfully to add data to an index through Splunk Python SDK, but no events are found in the index?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163988#M2190</link>
      <description>&lt;P&gt;The problem is about ": : : ". How to fix it????&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 08:18:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-python-file-executes-successfully-to-add-data-to-an-index/m-p/163988#M2190</guid>
      <dc:creator>kairat</dc:creator>
      <dc:date>2018-07-09T08:18:09Z</dc:date>
    </item>
  </channel>
</rss>

