Splunk Enterprise

Looking for a Splunk search to list all indexes that were not used by users for last 30 days

sab007
Engager

Hello Splunkers,

I'm looking for a Splunk search to list all indexes that were not used by users for last 30 days. I've tried the below query from audit logs, but it's not giving me the accurate results. This query is only giving me few indexes but not all the indexes that we used. 

index=_audit sourcetype=audittrail action=search info=granted (NOT TERM(index=_*))
| where match(search, "index\s*(?:=|IN)")
| rex max_match=0 field=search "'search index=(?<used_index>\w+)'"
| stats count by used_index

Appreciate if anyone could share some thoughts on this?

Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

In addition to @richgalloway comment, that will give you a list of probable used indexes, but if you then want to compare that to indexes that have received data, you could add the following to his SPL

| eval source="search"
| append [
  | tstats count where index=* by index
  | eval source="data"
  | rename index as used_index
]
| stats values(source) as sources by used_index
| where mvcount(sources)=1 AND sources="data"

This will then show you those indexes that have data in the time period, but have not been seen as being searched.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I revised the regex a little to better extract index names.

index=_audit sourcetype=audittrail action=search info=granted (NOT TERM(index=_*))
| where match(search, "index\s*(?:=|IN)")
| rex max_match=0 field=search "\bindex\s*=\s*\\\"?(?<used_index>\w+)"
| stats count by used_index

Even with that, however, you won't see all index names.  That's because not all searches specify an index name.  Some may use a macro while others may rely on the role's default indexes.

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

Index This | Why did the turkey cross the road?

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

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...