Getting Data In

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
Get Updates on the Splunk Community!

Why You Can't Miss .conf25: Unleashing the Power of Agentic AI with Splunk & Cisco

The Defining Technology Movement of Our Lifetime The advent of agentic AI is arguably the defining technology ...

Deep Dive into Federated Analytics: Unlocking the Full Power of Your Security Data

In today’s complex digital landscape, security teams face increasing pressure to protect sprawling data across ...

Your summer travels continue with new course releases

Summer in the Northern hemisphere is in full swing, and is often a time to travel and explore. If your summer ...