Splunk Search

Join two seaches with a range time

slorente
Explorer

Hello there.

I have reading some answers similar to mine, but none of them fit with what I have in mind.

I have two searches, both of them in different indexes.

Search A:

index=indexA field1="value1" (field2="value2" OR field3="value3)
| eval _time=strptime(fieldTime,"%Y-%m-%d %H:%M:%S")
| eval ID=field4.field5.field6
| stats latest(field7) as F7, latest(field8) as F8, latest(field9) as EstimatedTime by ID 

Search B:

index=indexB AND NOT ("some_value1" OR "some_value2") earliest=1 latest=now
| dedup _time
| append [
    search index=indexB "some_value1" OR "some_value2" earliest=1 latest=now
    | dedup _time
    | transaction maxpause=1h maxevents=2
    | where eventcount=2
    | search F8="*" field10="*"
    | lookup some_lookup.csv field11 as F8 field12 as F12 OUTPUT field13 as F13
    | search F13="*"
]
| lookup some_lookup.csv field11 as F8 field12 as F12 OUTPUT field13 as F13
| streamstats last(_time) as InitialTime first(_time) as FinalTime window=2

I want to check if the EstimatedTime field from the search 1 is in the range of the time fields InitialTime and FinalTime from the second search to asign the correct data. How could I get this?

Regards.

0 Karma
1 Solution

slorente
Explorer

I found a solution. I use an append to unify the two SPL, sort by _time and use transaction with startswith=eval(match()).

That do the trick.

Regards.

View solution in original post

0 Karma

slorente
Explorer

I found a solution. I use an append to unify the two SPL, sort by _time and use transaction with startswith=eval(match()).

That do the trick.

Regards.

0 Karma

Richfez
SplunkTrust
SplunkTrust

@slorente - EDIT -

I didn't realize this but if you have a code block inside - or even near - a list, it seems to break the code block.

I changed your post around just a bit to fix that, substituting bold for those list items and all seems well enough now.

-Rich

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...