1. Main question - how do you define "not used"?
2. While indexes are discrete "bags" for events, sourcetype is just a label. Yes, it bears a significant meaning for Splunk functionalities but you can even make each event have a separate sourcetype. So why would you want to know what your "unused" sourcetype are?
I am listing the index name using rest query and then checking those index name with audit or internal to to find if how many index used, sourcetype used, and HOW Many index not used in splunk.
Also i need to identify which indexes and sourcetypes have not received any data for a period exceeding 90 days.
Again - depends on what "unused" means here.
Just listing defined indexes which hadn't received any data - that should be pretty straightforward indeed - check your defined indexes (it might be difficult though if you're on distributed setup and don't have the capability of spawning rest to indexers!) and compare it with a summary of your data across all indexes. (be aware of the difference between _time and _indextime). Be aware though that if you have shorter retention periods than what you're searching through, you might not get valid data.
But that's it. Depending on what you mean by "unused", the rest of the task can be difficult or even impossible.
How is Splunk supposed to know what sourcetypes you might have had defined yesterday and haven't searched for them? Or something like that...
And if you have two or more SH(C)s connecting to the same indexer(s)...
That might get ugly quickly.
I have tried to get the index not used used any KO, but not getting all the details.
| rest /services/data/indexes
| fields index
| eval index=1
[index=_audit| stats count as accessed by index, search ]
| stats sum(accessed) as accessed, values(index) as index by
| fillnull accessed value=0
| where index=1 AND accessed=0
Total Index | Index Not used in Any Knowledge Object | Index has 0 data last 90 days |
100 | 25 | 10 |
the query is not getting expected result, i was runining for last 90 days but didnt get the result.
query for 90 days.
| tstats latest(_time) as lastTime where index=* by index, sourcetype
| eval age=now()-lastTime
| where age > 7776000
| eval lastTime=strftime(lastTime, "%Y-%m-%d %H:%M:%S")
| table index, sourcetype, lastTime
Try this, you can change the age value to 7776000 (90days)
the query is not getting expected result, I need to get the list of index which is not used by anyone