capture the size of the request and response in a policy

Not applicable

Hi,

I am looking for how to capture the size of the request and response in a policy in Kbs/Mbs, is there any variable available for this purpose.

I would really appreciate your help.

Thanks in Advance.

0 4 2,779
4 REPLIES 4

@sambitrathap , Welcome to Apigee Community !

Apigee Analytics does it for you out of the box. Apigee Edge automatically captures this data & send it to analytics. You can create a custom report & get the details by proxy / developer / developer app & various other dimensions.

See screenshot below.

5035-screen-shot-2017-06-07-at-114715-am.png

You can also read request & response content-length header using flow variables, For more details refer flow variables section in Apigee Docs.

Hope it helps. Keep us posted if any.

Hello Anil,
At runtime can we check the ML request size before sending it? (in case we are logging dynamic values in it and it might be big sometimes)

and what about the analytics report: does it show the ML requests as well ?

Regards

Not applicable

Hi Anil,

I am looking for, how to get the payload size in flow in a variable, so that I can use it later, I have tried the below way in a JS policiy , but its giving me null value:

var payLoadSize = context.getVariable("response.header.Content-Length");

I also checked the flow variables section in Apigee Docs, but could not find Content-Length varible.

Regards,

Sambit.

Hi @sambitrathap -- I just tried getting the content length in JavaScript exactly as you did and I got the length as expected. You've probably verified these things, but is your JavaScript policy on a response flow? If it's on a request flow, the value would be null. Is your target service actually returning the header "Content-Length"? You can look in the Trace tool to see the response headers that are returned.