Splunk Dev

Why are events sent directly to index over socket using python SDK not seen in event search?

shobhas
New Member

There is no error shown while sending data over socket using Python SDK. But the event is not available in search. Why?
import splunklib;
import config;
import splunklib.client as client
import socket

# Create a Service instance and log in
service = client.connect(
    host=config.splunkconfig.get("host"),
    port=config.splunkconfig.get("port"),
    username=config.splunkconfig.get("user"),
    password=config.splunkconfig.get("password"))

# Get the collection of indexes
indexes = service.indexes

# List the indexes and their event counts
for index in indexes:
    #count = index["totalEventCount"]
    print ((index.name))

# Retrieve the index for the data
myindex = service.indexes["main"]

# Open a socket
mysocket = myindex.attach(sourcetype="splunk_input_test")

# Send events to it
data=b'This is my splunk test event\r\n'
mysocket.sendall(data)
# Close the socket
mysocket.close()
Tags (1)
0 Karma

shobhas
New Member

also service.indexes is not listing all the indexes I have access to.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...