Splunk Search

Get the last Json Inserted document

sibbsnb
Path Finder

I have an Index where i store huge Json documents. I want the last document inserted which contains the latest state. What is the most efficient command.

1) tail 1
2) latest
3) dedup

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Since Splunk searches backward in time, tail will give you the oldest entry rather than the latest. I prefer to use 'head 1' to find the most recent event.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Since Splunk searches backward in time, tail will give you the oldest entry rather than the latest. I prefer to use 'head 1' to find the most recent event.

---
If this reply helps you, Karma would be appreciated.

sibbsnb
Path Finder

Great, thanks a lot. That helps. So i don't even need to mention any time modifiers. Just do head 1 and i get the latest Json.

0 Karma

somesoni2
Revered Legend

If you just want one records which was inserted/indexed recently, head is the command you need. If you need last indexed records by a field (say host or user) then dedup or stats latest can be used.

Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...