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
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...