Hi guyz,
I am new to scripted fields. I have logs with entries 'RequestExecuted' and RequestReceived' with their timestamps and connected by unique ID called 'TransactionId'. I am trying to get the time difference between RequestReceived' and 'RequestExecuted' . Below is my logic
´int timetaken = 0;
int start = 0;
String TransactionId;
int end = 0;
for (def dissect_item : params._source['dissect']) {
if (dissect_item['MessageIdentifier'] == 'RequestReceived') {
start = dissect_item['timestamp'].value.millis;
TransactionId = dissect_item['TransactionId'];
}
if( dissect_item['MessageIdentifier'] =='RequestExecuted' && dissect_item['TransactionId'] == TransactionId) {
end = dissect_item['dissect.timestamp'].value.millis;
timetaken = end - start;
return timetaken;
}`
and the data in the kibana looks like this:
Please help me as I have tried many ways but always getting an error.