<?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: python or python sdk example for adding data via services/receivers/simple rest in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191316#M2552</link>
    <description>&lt;P&gt;thanks Damien. the little preamble to this is that one needs to instantiate a client.connect object (service in the example). i followed this &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEE4"&gt;example&lt;/A&gt; for the connection setup. between your help and that, this was really painless. thank you. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
import splunklib.client as client

HOST = "localhost"
PORT = 8089
USERNAME = "admin"
PASSWORD = "changeme"

# Create a Service instance and log in 
service = client.connect(
    host=HOST,
    port=PORT,
    username=USERNAME,
    password=PASSWORD)
    
# Send an event over HTTP
# Retrieve the index for the data
myindex = service.indexes["obix"]
# Submit an event over HTTP
myindex.submit("This is my HTTP event", sourcetype="access_combined.log", host="local")

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Dec 2013 22:10:00 GMT</pubDate>
    <dc:creator>monzy</dc:creator>
    <dc:date>2013-12-30T22:10:00Z</dc:date>
    <item>
      <title>python or python sdk example for adding data via services/receivers/simple rest</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191314#M2550</link>
      <description>&lt;P&gt;is there an example in the python sdk examples that i can follow to post data to a splunk index via the services/receivers/simple REST endpoint ? if not via python sdk, perhaps something using urllib2 or some other python standard library. i am currently using the python postprocess module with curl as described &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTinput#receivers.2Fsimple"&gt;here&lt;/A&gt;. but there is probably a more elegant, sustainable, os independent, way to post data. &lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2013 20:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191314#M2550</guid>
      <dc:creator>monzy</dc:creator>
      <dc:date>2013-12-27T20:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: python or python sdk example for adding data via services/receivers/simple rest</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191315#M2551</link>
      <description>&lt;P&gt;Example code here : &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEE6#add2index"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEE6#add2index&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# Send an event over HTTP

# Retrieve the index for the data
myindex = service.indexes["test_index"]

# Submit an event over HTTP
myindex.submit("This is my HTTP event", sourcetype="access_combined.log", host="local")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The method you want to use (submit) is at line 1823 : &lt;A href="https://github.com/splunk/splunk-sdk-python/blob/master/splunklib/client.py"&gt;https://github.com/splunk/splunk-sdk-python/blob/master/splunklib/client.py&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2013 20:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191315#M2551</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-12-29T20:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: python or python sdk example for adding data via services/receivers/simple rest</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191316#M2552</link>
      <description>&lt;P&gt;thanks Damien. the little preamble to this is that one needs to instantiate a client.connect object (service in the example). i followed this &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEE4"&gt;example&lt;/A&gt; for the connection setup. between your help and that, this was really painless. thank you. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
import splunklib.client as client

HOST = "localhost"
PORT = 8089
USERNAME = "admin"
PASSWORD = "changeme"

# Create a Service instance and log in 
service = client.connect(
    host=HOST,
    port=PORT,
    username=USERNAME,
    password=PASSWORD)
    
# Send an event over HTTP
# Retrieve the index for the data
myindex = service.indexes["obix"]
# Submit an event over HTTP
myindex.submit("This is my HTTP event", sourcetype="access_combined.log", host="local")

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Dec 2013 22:10:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/python-or-python-sdk-example-for-adding-data-via-services/m-p/191316#M2552</guid>
      <dc:creator>monzy</dc:creator>
      <dc:date>2013-12-30T22:10:00Z</dc:date>
    </item>
  </channel>
</rss>

