Splunk Search

Why is dedup not giving me the earliest event?

cmamer
New Member

I'm attempting to consolidate records that share the same values in 3 fields, and I want to keep the event that has the earliest time.
I keep getting the same record (newest) even though I am sorting them by time:

dedup 1 licUser licType licPC sortby -_time

Any ideas?

Tags (3)
0 Karma

fdi01
Motivator

try like:

...|dedup  _time |sort -_time|table  licUser  licType  licPC  _time

or

...|sort -_time|stats first(licUser) first(licType) first(licPC) by _time|
0 Karma

kearaspoor
SplunkTrust
SplunkTrust

Dedup keeps the first event seen. Since searches are performed from most recent to oldest, it will keep the newest event regardless of what other things you attempt in the search string.

I'd recommend that you try | stats earliest(field)
See more here: http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/CommonStatsFunctions

0 Karma

cmamer
New Member

But this doesn't leave me with the fields I need to continue such as _time.

0 Karma

NOUMSSI
Builder

dedup command removes the subsequent duplicate results that match specified criteria. it's not means that it'll return the last event, but it return the first event that macth with creiterias. this event can be the first, the last ...

if you want the last, you can use last function to do that.

... |last(licUser) last(licType) last(licPC) by -_time|...
0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...