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!

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...

Splunk Observability for AI

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