How to get a response time in post proxy flow

Hello there,

I need to log a request's response time for each request to parse that data later using kibana. I've added js policy in post proxy flow that looks like that:

var client_start_time = context.getVariable('client.received.start.timestamp'); var client_end_time = context.getVariable('client.sent.end.timestamp');

print(client_end_time - client_start_time);

Somehow client_end_time is always -1. What is a proper way for doing that? I've looked everywhere and didn't find an answer.

Does anybody know why is that? Thanks!

1 1 423
1 REPLY 1

@Sergey Rastrigin,

The variable "client.sent.end.timestamp" gets populated only after the response is sent back by Message Processor to the Router. Since you are executing the JS policy in the response flow i.e., before the response is sent, you get -1.

Use Message Logging policy in Post Client Flow to log the response time variables and any other variables.