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!

Splunk Observability for AI

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

[Puzzles] Solve, Learn, Repeat: Dereferencing XML to Fixed-length events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...