Splunk Search

First and Last event of Transaction

Shashank_87
Explorer

Hi, I am working on a query where I need to join some events using a transaction command in Splunk. Below is my query where I am joining a particular web service request with a response using a "requestID" and then extracting the data. Now what happens is if the response contains an error, it will again try and may be next time it gets success. requestID remains same here.
Right now this query is just using the 1st response event which it encounters and reported as error even if it is not.

How do i extract the last of the responses so that i get the updated data whether it resulted in an error or success.

index=temp ("SoapMessage" "GetCustomerRequest") OR ("SoapMessage" "GetCustomerResponse")
| rex field=_raw ">(?[^<]+)<\/\w+?:requestID>"
| transaction requestID startswith="GetCustomerRequest" endswith="GetCustomerResponse" keepevicted=true
| search eventcount > 1

0 Karma

xavierashe
Contributor

try this:

 index=temp ("SoapMessage" "GetCustomerRequest") OR ("SoapMessage" "GetCustomerResponse")
| rex field=_raw "\>(?[^\<]+)\<\/\w+?\:requestID\>"
| transaction requestID startswith="GetCustomerRequest" endswith="GetCustomerResponse" keepevicted=true mvlist=true
| search eventcount > 1
| eval  last_response=mvindex(response, -1)
0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...