I am using below code to push data to splunk using Python SDk,script is executed successfully but i am not seeing any data in splunk.
import splunklib.client as client
service = client.connect(host='localhost',port=8089,username='username',password='password')
myindex = service.indexes["main"]
mysocket = myindex.attach(sourcetype='rajanish',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()
hi rajanish,
did you get this issue fixed. can you help me with the python code. i am also trying to push data to splunk.
I am new to splunk, so kindly help me