Archive

Not able to push data to splunk using python SDK

rajanishsinght
New Member

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()

Tags (1)
0 Karma

yaseenbe
New Member

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

0 Karma
Take the 2021 Splunk Career Survey

Help us learn about how Splunk has
impacted your career by taking the 2021 Splunk Career Survey.

Earn $50 in Amazon cash!