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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...