Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to run JS/kvm policy regardless of 2xx or 4xx responses from target server?

Hello everyone.

I'm integrating datadog into our apigee proxies but having an issue with logging. More info on the datadog apigee integration here https://docs.datadoghq.com/integrations/apigee/.

The issue I'm facing is I want this JS policy to run regardless of the response from the target server. Currently, when an error is received from the target server–4xx, 5xx– it enters the error flow, and the JS policy to send logs doesn't get sent.

I've tried placing it in PostClientFlow but it can't handle JS and KVM operations needed for the apikey. I've also tried placing the JS policy in a DefaultFaultRule but that also didn't work.

Does anyone have comments or suggestions?

Solved Solved
1 2 244
1 ACCEPTED SOLUTION

I've also tried placing the JS policy in a DefaultFaultRule but that also didn't work.

It will definitely run if you configure your DefaultFaultRule correctly. You may need to use AlwaysEnforce = true.

 

<ProxyEndpoint name='endpoint1'>
  <Description>Proxy Endpoint 1</Description>
  <HTTPProxyConnection>
    <BasePath>/loopback</BasePath>
    <Properties/>
    <VirtualHost>secure</VirtualHost>
  </HTTPProxyConnection>

  <FaultRules/>
  <DefaultFaultRule name="default-fault-rule">
    <Step>
      <Name>AM-Inject-Proxy-Revision-Header</Name>
    </Step>
    <!-- pay attention here -->
    <AlwaysEnforce>true</AlwaysEnforce>
  </DefaultFaultRule>

 

 

View solution in original post

2 REPLIES 2

I've also tried placing the JS policy in a DefaultFaultRule but that also didn't work.

It will definitely run if you configure your DefaultFaultRule correctly. You may need to use AlwaysEnforce = true.

 

<ProxyEndpoint name='endpoint1'>
  <Description>Proxy Endpoint 1</Description>
  <HTTPProxyConnection>
    <BasePath>/loopback</BasePath>
    <Properties/>
    <VirtualHost>secure</VirtualHost>
  </HTTPProxyConnection>

  <FaultRules/>
  <DefaultFaultRule name="default-fault-rule">
    <Step>
      <Name>AM-Inject-Proxy-Revision-Header</Name>
    </Step>
    <!-- pay attention here -->
    <AlwaysEnforce>true</AlwaysEnforce>
  </DefaultFaultRule>

 

 

Thank you @dchiesa1! I think I was missing the AlwaysEnforce tag. For anyone looking for a solution, I added the JS policy in both the PostFlow and the DefaultFaultRule to handle successes and errors from the target server