Splunk Search

Find searches that reference indexes that no longer exist

dashe
Engager

Hi,

I'm trying to clean up an old splunk cloud instance. one thought that occurred to me is find scheduled searches that reference indexes that don't exist anymore, they have long been cleaned up and deleted but scheduled searches may still exist against these deleted indexes.

I tried looking in internal indexes but don't see any sort of warning messages for index does not exist.

Does anyone know if such a warning message shows up that I can then use to deactivate these searches?

thanks in advance

Dave

Labels (1)
0 Karma

sainag_splunk
Splunk Employee
Splunk Employee

 

I think there is no easy way because, as @richgalloway  mentioned, there is no warning when a search tries to use an index that doesn't exist. Even if you choose result_count=0, you will get a lot of false positives. The best way is to run a search against the saved searches and validate with your existing indexes.

The most reliable approach is the manual two-step method:

Step 1: Get scheduled searches and their referenced indexes

 
 
| rest /services/saved/searches | search disabled=0 is_scheduled=1 | rex field=search "index\s*=\s*(?<referenced_index>[^\s\|]+)" | stats values(title) as searches by referenced_index

Step 2: Get your current indexes

 
 
| rest /services/data/indexes | fields title 



If this Helps, Please Upvote.

richgalloway
SplunkTrust
SplunkTrust

@sainag_splunk's answer is correct, but be aware that not all searches specify an index name and those that do might do so using a wildcard.  This is a Hard Problem addressed in the .conf24 talk "Maximizing Splunk Core: Analyzing Splunk Searches Using Audittrail and Native Splunk Telemetry", which offers some ways to get the indexes used by a search.

---
If this reply helps you, Karma would be appreciated.

richgalloway
SplunkTrust
SplunkTrust

There is no warning when a search tries to use an index that doesn't exist.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...