Splunk Search

Is there a fast way to search all indexes to list just the index names and the date/time of the last event or update?

jwleppert
New Member

Is there a fast way to search all indexes to list just the index name and the time/date of the last event or update?
My searches are taking entirely too long. I tried an 'eventcount' search which runs fast, but it only provides sourcetype names and not the index names.

0 Karma
1 Solution

sjohnson_splunk
Splunk Employee
Splunk Employee

You should be able to use a rest command to get the results:

|rest /services/data/indexes | table title

View solution in original post

0 Karma

splunkton
Path Finder

Give a shot hope fully it solves your query

index=* | eval latest=now()|table index latest converttime |eval converttime=strftime(latest,"%m/%d/%y %H:%M:%S") |dedup index latest

0 Karma

jwleppert
New Member

That looks to work but it runs too slow. Any query I run starting with Index=* runs too slow
I was hoping something faster using dbinspect or tstats

0 Karma

splunkton
Path Finder

try this

| tstats latest(_time) as latest by index |eval converttime=strftime(latest,"%m/%d/%y %H:%M:%S")|fields index converttime

0 Karma

ryanoconnor
Builder

This should get you what you need:

index=* 
| stats latest(_time) as latestTime by index
| eval latestTime=strftime(latestTime,"%x %X")
0 Karma

jwleppert
New Member

That looks to work but it runs too slow. Any query I run starting with Index=* runs too slow

0 Karma

ryanoconnor
Builder

This might be faster:

| eventcount summarize=false index=* index=_* 
| dedup index | fields index  | map maxsearches=100 search="|metadata type=sourcetypes index=\"$index$\"
| eval index=\"$index$\"" | eval latestTime=strftime(lastTime,"%x %X") | table latestTime index | stats max(latestTime) by index
0 Karma

jwleppert
New Member

Error in 'map': Did not find value for required attribute 'index'.

0 Karma

sjohnson_splunk
Splunk Employee
Splunk Employee

You should be able to use a rest command to get the results:

|rest /services/data/indexes | table title

0 Karma

jwleppert
New Member

|rest /services/data/indexes | table title updated

  • this gives duplicate index names
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Of course, it does. Your indexes reside on multiple indexers with different update times. If you don't want duplicates you have a couple of options.

 |rest /services/data/indexes | dedup title | table title updated

 |rest /services/data/indexes | stats first(updated) by title
---
If this reply helps you, Karma would be appreciated.

jwleppert
New Member

That runs quick, thx!

0 Karma

jwleppert
New Member

that doesn't give the time/date of the last event

0 Karma

richgalloway
SplunkTrust
SplunkTrust

This does:

|rest /services/data/indexes | table title updated
---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Does it have to be a query? The Settings->Indexes screen shows the information you seek.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...