Splunk Search

How to select one event from a transaction?

juanpavergara
Engager

I need to group the events (in this case by JSESSIONID) and select the one with the max date

I have the groups with the following query:

date_month="march" date_mday>="25" date_mday<="26" | transaction JSESSIONID

How can I get every transaction only with the newest event?

TKS!

0 Karma

niketn
Legend

@juanpavergara... do you need only one event for each JSESSIONID with only the latest event(or you need correlated events as well with time of transaction as latest time?)
Instead of transaction you should try dedup command, as transaction will be very expensive command specially when you do not need correlated event rather just the latest event. Since latest data is fetched first, dedup will get only the latest match for each JSESSIONID

date_month="march" date_mday>="25" date_mday<="26" 
| dedup JSESSIONID
| table _time JSESSIONID _raw

Instead of _raw you can select specific fields you need.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

koshyk
Super Champion

hi
can u please try

date_month="march" date_mday>="25" date_mday<="26" | transaction JSESSIONID | stats latest(JSESSIONID)

may be you can try any of the option try to fit whichever best

first(JSESSIONID)
latest(JSESSIONID)
last(JSESSIONID)
earliest(JSESSIONID) 
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

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 ...