log request / response when transactions fails with an error in apigeex - google cloud

Is there a way to log complete request & response along with headers & query params in case of any errors in apigeex Google cloud project? 

We have an openidconnect flow where apigeex is acting as identity broker & we see intermittent errors so we wanted to collect the logs to figureout the payload that was sent from apigeex & received from IDP.

@kurtkanaskie @dchiesa1 

 

 

Solved Solved
1 4 314
1 ACCEPTED SOLUTION

You would have to collect that information at each of the Flow Hook locations and build up the logging message to use in the logging policy in Post Client Flow logging policy.

This is an example Shared Flow that uses JavaScript to build a "logging_message" with all that information:  https://github.com/kurtkanaskie/log-set-values-v1

View solution in original post

4 REPLIES 4

Sure, you can do that. Probably you will want to use a FaultRule, to set a context variable.  And then in the PostClient flow, check that context variable and write to the log if it is set. 

Hi Raghu,

You can configure a Shared Flow to capture logging information at each of the Flow Hook locations, then log the message to Cloud Logging or elsewhere using a Service Callout or Message Logging policy in a Post Client Flow for the proxy. You can do the Shared Flow and Flow Hook configuration without changing the API Proxy, but you'll have to add a Shared Flow with the logging policy to the Post Client Flow to each API Proxy. I recommend using a Shared Flow for that as you'll only need to modify the proxy once, then you can control the execution of the logging policy in the Shared Flow.

A quick solution would be to just use a Shared Flow to log various variables as Dino suggested. You can create a Shared Flow for that in your Post Client Flow so you can control its execution without re-visiting the API Proxy.

Thanks @kurtkanaskie @dchiesa1 . We already have a splunksharedflow & a message logging policy that is being called using FlowCallout in the Response step of PostClientFlow which logs to splunk. Currently we log the transaction metadata like response time, uri, clientIP etc but now the requirement is to log the request.content & response.content only in case of Fault scenario or backend response code not 200s. Is there a way to add a condition in the message logging policy to log payloads along with headers/query params in case of fault?

You would have to collect that information at each of the Flow Hook locations and build up the logging message to use in the logging policy in Post Client Flow logging policy.

This is an example Shared Flow that uses JavaScript to build a "logging_message" with all that information:  https://github.com/kurtkanaskie/log-set-values-v1