Splunk Search

Attempting to run eval using value from min row returned by stats

hzane
Engager

I have a list of events with columns such as:
type,event_time,event_id,create_date

My objective is to find the lowest event_time and subtract the create date to pop out a calculated value, called here "ttn".

index=events 
type=notification 
|stats min(event_time) as init_time by event_id
|eval ttn = init_time - create_date

It seems so close! If I change create_date to a number, that works. I was experimenting with appendpipe but to no avail.
This is my first week using Splunk and figuring out how to combine stats and eval in this manner is going to help immensely.

Thank you.

0 Karma
1 Solution

hzane
Engager

I ended up getting the desired result by nesting my eval statement inside the stats clause.

stats min(eval(event_time-create_date)) as ttn by tid

Pretty easy. Now if I can get these joins to work I will be home free!

View solution in original post

0 Karma

hzane
Engager

I ended up getting the desired result by nesting my eval statement inside the stats clause.

stats min(eval(event_time-create_date)) as ttn by tid

Pretty easy. Now if I can get these joins to work I will be home free!

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...