Splunk Search

How do i search next log entry after the one I originally searched for?

David_M
Explorer

I'm very new to splunk.  What I'm trying to search for is the next log entry after the entry I search for.  For example, I have this log entry from a search:

search: index=dhcp DHCPREQUEST

result: 

8/1/22
10:00:00.000 AM
 
Aug 1 10:00:00 b826c80c7n dhcpd[23809]: DHCPREQUEST for 10.23.1.131 from 00:50:56:9e:82:3e via eth0

 

What I'm trying to find is the next log entry after this.  Any suggestions would help.

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Do you mean the DHCPREQUEST event in the index in time order, or just the next event in the index by time?

Assuming you mean the latter, if DHCPREQUEST is the latest event, then there won't be a next event (just yet), so you could copy each event to the previous event and then search for DHCPREQUEST in the current events. You could try something like this

index=dhcp
| streamstats window=1 current=f values(_raw) as previous
| regex _raw="DHCPREQUEST"

 

0 Karma

David_M
Explorer

Hello TWhisperer,

    Well that didn't quite do it.  But after pouring over my DHCP logs and some packet captures I figured out to do what I want is going to require my DHCP server adding the DHCP transaction ID to syslog, if that's possible.  Getting the log entries around the target entry still doesn't narrow things down enough.  But that you for th suggestion, I'm sure I'll be using it at some point.

Tags (1)
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 ...