Deployment Architecture

Oldest event from source or sourcetype

suhprano
Path Finder

I have a distributed index model and I would like to use the search head to find out what the oldest event is per source or sourcetype.

I tried using the metadata command but nothing comes up, do I have to do this search on the indexer? Is there a way to search this just on the search head?

Tags (1)
1 Solution

hazekamp
Builder

suhprano,

The "| metadata" command will distribute to all servers in your distributed search pool. The reason you may not be getting results back could be caused by your data being in non-default indexes. Have you tried:

| metadata type=sources index=*

Your role should also have the get_metadata capability (get_metadata is a shipped capability of all roles).

Update:
Based on your comment below make sure you are using valid types. Valid types are:

type=sources
type=hosts
type=sourcetypes

View solution in original post

usethedata
Path Finder

I wanted the timestamp of the oldest event to be in human interpretable form, so I added a strftime call. For me, to find the oldest record from my vpn log source, I used

| metadata type=sources index=* | where source="/log/sources/myvpn/myvpn.log" | eval str_firstTime=strftime(firstTime,"%Y-%m-%d %H:%M")

That gave me the oldest event for that particular source in a format that was easy to read

0 Karma

hazekamp
Builder

suhprano,

The "| metadata" command will distribute to all servers in your distributed search pool. The reason you may not be getting results back could be caused by your data being in non-default indexes. Have you tried:

| metadata type=sources index=*

Your role should also have the get_metadata capability (get_metadata is a shipped capability of all roles).

Update:
Based on your comment below make sure you are using valid types. Valid types are:

type=sources
type=hosts
type=sourcetypes

suhprano
Path Finder

Thanks for the info, but it appears that it only retrieves one epoch time for all source/sourcetypes. Is there a way to find the oldest event regarding a particular sourcetype?

0 Karma

hazekamp
Builder

Your search looks good except for type=sourcestypes. Should either be type=sources or type=sourcetypes

0 Karma

suhprano
Path Finder

Sorry, I'm still not seeing it. I'm also trying on the actual indexes and nothing comes up. This is the search I'm running:

| metadata type=sourcestypes index=*| stats min(firstTime) as firstTime

Could it be the (firstTime) field? I don't know if that's the right syntax or parameter I should be passing.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...