Getting Data In

Delete index and recreate using python sdk

bertm81
New Member

Hi,
I am trying to delete all data from an index for automated testing using the python sdk. The splunk.client.index.clean works intermittently but times out often. I seen this question: where in the last comment gblock [Splunk] suggest not using the clean function but delete the index and recreate instead. I have tried this in the below code function but when I try to recreate, I get an error saying

HTTPError: HTTP 404 Not Found -- Index "testindex" is being deleted; name still unavailable

Sode Snippet

def clear_index(index):
service = splunk_connection.get()
if index.state.content.disabled == 1:
index.enable()
name = index.name
service.indexes.delete(name)
service.indexes.create(name)

the user is created as follows.

/opt/splunk/bin/splunk add user usernasme -password password -role admin -auth admin:changeme'

0 Karma

bertm81
New Member

Bumping this as I am still having this issue.

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...