Hi,
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
Here are my code
import splunklib.client as client
import sys,os
import socket
............................
Create a Service instance and log in
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD,
owner=OWNER,
app=APP)
Retrieve the index for the data
myindex = service.indexes["test_index"]
myindex = service.indexes.create("test_index2")
with myindex.attached_socket(sourcetype='test') as sock:
#sock.send("Test event\r\n")
sock.close()
Open a socket
mysocket = myindex.attach()
Send events to it
mysocket.send("This is my socket event\r\n")
Close the socket
mysocket.close()
print "everything done"
Code Type 2 :
import splunklib.client as client
import sys,os
.................................
Create a Service instance and log in
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD,
owner=OWNER,
app=APP)
Retrieve the index for the data
myindex = service.indexes["test_index"]
Submit an event over HTTP
myindex.submit('This is my HTTP event',sourcetype='test', host='localhost')
Please verify and let me know what changes i have to do?
... View more