Splunk Search

Index Earliest and Latest events

mrccasi
Explorer

Hi,

 

I currently have this search that gets the earliest and latest timestamp of index. But since I am running this search in All time Time range, it is very slow.

| tstats earliest(_time) as earliestTime latest(_time) as latestTime where index=* by index
| eval strfearliestTime=strftime(earliestTime,"%Y/%m/%d %H:%M:%S")
| eval strflatestTime=strftime(latestTime,"%Y/%m/%d %H:%M:%S")

Do you have any other options on getting this information? I also tried using | rest command. But I am not getting the minTime and maxTime I saw on queries that others are using.

| rest /services/data/indexes
| eval indexSize=tostring(round(currentDBSizeMB/1024,2), "commas"), events=tostring(totalEventCount, "commas"), daysRetention=frozenTimePeriodInSecs/60/60/24
| foreach *Time
[| eval <<FIELD>>=strptime(<<FIELD>>,"%Y-%m-%dT%H:%M:%S%Z"), <<FIELD>>=strftime(<<FIELD>>,"%m/%d/%Y %H:%M:%S") ]
| fillnull value="n/a"
| table title, splunk_server, indexSize, daysRetention, events, maxTime, minTime
| rename title as "Index Name", splunk_server as "Splunk Server" indexSize as "Current Size on Disk (GB)", daysRetention as "Retention Period in Days", events as "Count of events", maxTime as "Most Recent Event", minTime as "Earliest Event"

Can you please suggest other options? Thank you!

Labels (1)
0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

based on MC's query this will do it

| rest splunk_server=<your idx servers> /services/data/indexes 
  | join type=outer title [
    | rest splunk_server=<your idx servers> /services/data/indexes-extended 
  ]
| fields title minTime maxTime

r. Ismo 

0 Karma

mrccasi
Explorer

Hi,

For some reason our rest command really don't have values in mix and max time. I have used dbinspect instead to get the earliest and latest events per index.

Thank you.

0 Karma
Get Updates on the Splunk Community!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...