First Event
17:09:05:362 INFO com.a.b.App - Making a GET Request and req-id: [123456]
Second Event
17:09:06:480 INFO com.a.b.App - Output Status Code: 200 req-id:"123456"
I tried to use index="xyz" container="service-name" | transaction "req-id" startswith="Making a GET Request" endswith="Output Status Code" | table duration but it is also not working.
I want to calculate duration of above two events for every request. I went over some solutions in splunk and Stack Overflow, but still can't get the proper result.
Try doing it with
statsinstead:This will extract the "req-id" into a field named
req_id, and the start and end of the sequence into a field namedsequencePresuming the sample data you shared is correct, when you
stats values(sequence) as sequence, it will put the "Making..." entry first and the "Output..." entry secondBecause
values()will do this, when youmvexpandand then split thevalues()'d field part intosequenceandtime, they'll be in the proper orderIf the sample data is incomplete, you may need to tweak the regexes for populating
sequence