Splunk Search

How to get Index or Sourcetype not accessed or used by anyone in splunk

harishsplunk7
Explorer

I am want to get the list of Index and sourcetype which is not used by anyone for more than 90 days. 

 

Labels (8)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

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?

0 Karma

harishsplunk7
Explorer

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.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

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.

0 Karma

isoutamo
SplunkTrust
SplunkTrust
Of course it depends on what “unused” means and what kind of role you have. I expect that you have admin role which can access all indexes. But as @PickleRick said if your role haven’t access to all indexes or you role haven’t granted capability to use remote rest to indexers then we have one additional issue. Fortunately we have https://splunkbase.splunk.com/app/6368 which help you on those cases, but still there will be other challenges.
0 Karma

isoutamo
SplunkTrust
SplunkTrust
This is quite often asked question when people want know are there unused indexes etc. you could look those by searching with google.
Short answer is you can’t get this kind of list which is 100% accurate. There are so many ways how you can access that data and there is no requirement that users must use index name or sourcetype names on queries.
Of course you can get some estimates and you can get list of indexes and sourcetypes which are used, but there is no way to get list of unused ones!
0 Karma

harishsplunk7
Explorer

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 IndexIndex Not used in Any Knowledge ObjectIndex has 0 data last 90 days
1002510
0 Karma

harishsplunk7
Explorer

the query is not getting expected result,  i was runining for last 90 days but didnt get the result. 

 

0 Karma

kiran_panchavat
Influencer

@harishsplunk7 

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

 

Did this help? If yes, please consider giving kudos, marking it as the solution, or commenting for clarification — your feedback keeps the community going!
0 Karma

kiran_panchavat
Influencer

@harishsplunk7 

Try this, you can change the age value to 7776000 (90days)

kiran_panchavat_0-1740560355541.png

kiran_panchavat_1-1740560416894.png

 

 

Did this help? If yes, please consider giving kudos, marking it as the solution, or commenting for clarification — your feedback keeps the community going!
0 Karma

harishsplunk7
Explorer

the query is not getting expected result,  I need to get the list of index which is not used by anyone

0 Karma
Get Updates on the Splunk Community!

Detecting Brute Force Account Takeover Fraud with Splunk

This article is the second in a three-part series exploring advanced fraud detection techniques using Splunk. ...

Buttercup Games: Further Dashboarding Techniques (Part 9)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Buttercup Games: Further Dashboarding Techniques (Part 8)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...