Splunk Search

Latest time and the corresponding raw data

prettysunshinez
Explorer

Hi,
Can anyone help me how to get the latest time of an event and its corresponding raw logs(_raw).
When i use stats latest(_time),values(_raw)..
I get the latest time but a consolidated list of raw logs.

Tags (1)
0 Karma

arjunpkishore5
Motivator

Hi @prettysunshinez

In your case, you don't need to use stats, all you need is this

index= "search_string" 
| head 1 

If you need this in a table format, just add | table _time, _raw to the end of your query

This will give you the latest record. Please try and let me know if this is what you were looking for. Please mark as answer if yes.

Cheers.

0 Karma

rmmiller
Contributor

I think you want this instead:

stats latest(_time), latest(_raw)

Hope that helps!
rmmiller

0 Karma

prettysunshinez
Explorer

Can someone help please

0 Karma

arjunpkishore5
Motivator

Could you please elaborate or post the query ? Are you just trying to get the latest record in the index ?

0 Karma

prettysunshinez
Explorer

I'm looking for the latest time and _raw data of a particular string.

index= "search_string" |stats latest(_time) as Latest,values(_raw)

In the result I'm getting the latest time but all the values of _raw instead of the latest one.

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

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 ...