Splunk Search

Querying when the last time, an event was seen from various hosts in the system

msg4sunil
Path Finder

How to know the last event's time from each of the hosts in the system?.  The output can be of the below format?

host1|datetime

host2|datetime

 

thank you

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Since host is an indexed field you can use

| tstats latest_time by host where index=XXX
0 Karma

msg4sunil
Path Finder

@PickleRick , sorry, I am a normal user and have access to only specific index. Running the above command is failing.

Error in 'tstats' command: Invalid argument: 'index=indexname

 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Try without the whole where condition.

0 Karma

msg4sunil
Path Finder

see the below error

Error in 'TsidxStats': A field for an aggregate function is missing or invalid. Aggregate functions require fields with valid values to complete their arguments.
 
0 Karma

PickleRick
SplunkTrust
SplunkTrust

I rarely do the earliest/latest and so on 🙂

Probably max(_time) or latest(_time) will be what you need (they are not the same thing though!). As an excercise, think about the difference between max(_time) and latest(_time) 😉

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...