Splunk Search

How to match two lines by a common ID within the same file and extract a field from the second line?

achetreanu
New Member

How can I match 2 lines of the same file that have a random number of other lines between them?

1111 Start Sub Transaction. New Id 1115
other lines here 
1115 Transaction End. No Funds Available

I need to match them on ID = 1115 and extract the result (in this case "No Funds Available").
Thank you.

Tags (2)
0 Karma

woodcock
Esteemed Legend

Like this:

... | rex "^(?<firstWord>\w+).*(?<lastWord>\w+)$" | eval ID=if(isnumber(lastWord), lastWord, firstWord) | stats list(_raw) by ID
0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...