Splunk Search

Using Eval to get timespan to apply to subsearch

ltrand
Contributor

I'm looking for a way that I can take some logon logs and figure out the firewall logs for only when the user had the IP. Because it's a VPN pool, the IP's refresh and get reused quickly, so I'm trying to build a correlation that can positively match the activity to an endpoint.

What I have so far:
(sourcetype=WinEventLog:Security AccountName="username" | transaction TaskCategory startswith=Logon endswith="Logon/Logoff"| table _time TaskCategory Source_Network_Address

I would like to do a subsearch that is logically similar to this:

in sourcetype=fwlogs where src_ip=Source_Network_Address starts with transaction start-time-ends with transaction-end-time

Any thoughts?

Tags (3)
0 Karma

woodcock
Esteemed Legend

This should do the trick (replace &lt; with "<" and &gt; with ">"; stupid markdown bugs):

sourcetype=WinEventLog:Security AccountName="username"
| transaction TaskCategory startswith=Logon endswith="Logon/Logoff"
| eval startTime=_time | eval endTime=_time+duration
| map search="search sourcetype=fwlogs src_ip=$Source_Network_Address$ _time&gt;=$startTime$ _time&lt;=$endTime$
0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...