ApigeeX targetserver and postflow in proxy endpoint

Hi,

I have a simple proxy which forward the incoming request to a target server and send back the response to the client.

I want to log the response received from the target server and the response sent to the client.

To archieve this, I put :

  • a response PreFlow in the Target endpoint to log the response received from the target server
  • a response PostFlow in the Proxy endpoint to log the response sent to the client

Everything is working, except when the proxy received an error from the Target server : the response PostFlow in the Proxy endpoint is not executed even if I put a FaultRule in the Target endpoint.

Thank you for your answer

Hi @vbroucke , thank you for your question and for your patience! We’re closely following this conversation and ensuring you get a response. In the meantime, we’d like to invite other community members to share their insights.

Also, don’t forget to join us at our upcoming virtual event this week on Nov 14, “Spec-Driven Development for Apigee: A Fully Automated CI/CD Approach.” Your participation is always welcome!

:backhand_index_pointing_right:t3: Register here!

Hi, a great solution for these types of logging requirements is the PostClientFlow - it runs always after the flow is completed, see more info here: https://cloud.google.com/apigee/docs/api-platform/fundamentals/what-are-flows#designingflowexecutionsequence-havingcodeexecuteaftertheclientreceivesyourproxysresponsewithapostclientflow

The great thing about PostClientFlow is that it always runs after the client gets sent the response, so you have access to all info from the target, errors, responses, etc.. and you can then push them to logging or tracing without impacting the response to the client..

1 Like

Hi,

Thank you for your answer!

The PostClientFlow is not possible for me because I have to execute some Javascript code but it’s not allowed in the PostClientFlow …

Ok understand, the FaultRule will catch the error, but not help you resume the normal response flow… I would check if you can continue on error by setting the success codes for the target, or just adding your logging policy to the fault handling as well.. either way should work.

Hi @vbroucke , thank you for your question. We appreciate the responses provided @tyayers . :blush:

If either of the provided responses addresses your question, please consider marking the response as an accepted solution. This helps other community members who might have similar questions.

Additionally, we encourage you to explore our latest articles and resources in the community. :bookmark_tabs:

Hi @vbroucke , @tyayers ,

What I would do in order to avoid the code duplication (“adding your logging policy to the fault handling as well”) is to

  1. create a sharedFlow (SF), with the required functions (javascript)
  • I like to put here only those steps of the logging process, that are not able to run in the postClientFlow
  1. use the same SF in the response flow, and in the default response flow as well.
  2. put the remaining logging actions in the postClientFlow, just as @tyayers said.

Br,
Marcelo