Splunk Search

how to find the earliest and latest event in an index?

Contributor

I simply looking for the fist event in an index and the last... to determine how long it took to index x data.

any suggestions? i couldn't seem to figure out that query.

Tags (3)
1 Solution

Influencer

Do you mean the time when the event has been indexed? Then the query would be:

index=<your_index> | stats min(_indextime) as min_indextime max(_indextime) as max_indextime | convert ctime(min_indextime) ctime(max_indextime)

View solution in original post

Splunk Employee
Splunk Employee

Try this
| metadata index=main type=hosts | stats min(firstTime) max(lastTime) by host

0 Karma

Path Finder

look at
Settings > DATA > Indexes menu.
There are earliest and last event time by Index.

0 Karma

Influencer

Do you mean the time when the event has been indexed? Then the query would be:

index=<your_index> | stats min(_indextime) as min_indextime max(_indextime) as max_indextime | convert ctime(min_indextime) ctime(max_indextime)

View solution in original post

Contributor

i do have DATATIME_CONFIG = current.

0 Karma

Contributor

i ended up w/ max(_time) and min(_time) .. convert was very helpful. thank you both.

0 Karma

Influencer

_time and _indextime are only equal when you use DATETIME_CONFIG = current in your props config of if no timestamp was detected in the event.

0 Karma

Influencer

_indextime is always the time when the event has been index. _time can be a different time, for example when the time found within an event is used

0 Karma

Contributor

whats the difference between _indextime and _time?

0 Karma

Super Champion

You can look at the index event times using something like this:

| metadata index=main type=hosts | stats min(firstTime) max(lastTime)

Or, to examine individual events, you can compare the _time and _indextime fields:

 index=main | eval lag=_indextime-_time | stats avg(lag) ...

Do either of these help?

Builder

Hi Lowell,

When I try this command, | metadata index=main type=hosts | stats min(firstTime) max(lastTime), all I get is two columns, min(firstTime) max(lastTime) with time in seconds.

Can you please advise where I am getting it wrong ?
Thanks.
Dev

0 Karma

Contributor

This was helpful.

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!