stop/start the traffic in Apigee layer when backend API is timeout

Hi ,

I am using apigee cloud and have a requirement, to stop the traffic to backend api in Apigee layer when any backend api is timeout (http error code 504) for 10 times and again flow the traffic to backend from apigee after 10 mins.

Please suggest , how to know which api is timeout for 10 times (any management api ?) and how to stop/start the traffic to backend .

0 10 459
10 REPLIES 10

Any suggestion from anyone ? Please suggest.

I guess you need to manage quota (or cache for quota) and count API failures for a particular amount of time. Cache for 10 minutes can fit. Your key for cache is your service basepath\uuid, and value is the count of the timeouts. First time you have time out, create cache entry for 10 minutes and start the count.

Then, count service A failures (timeouts) for your quota.

Create condition rule that states: if service (Y) have quota X = 10, Raise Fault. After 10 mins cache will die, and we can go again.

Edit: use solution that Dino provided

There is a structure called a "TargetServer" in Apigee that, coupled with Health Monitoring, does what you want.

You need to configure a HealthMonitor for your TargetServers.

Wow, Dino, I knew I've missed something, and I tried such functionality some time ago on one of the POC's, how can I missed that...

@Dino-at-Google if HealthMonitor is enabled and target server was removed from the rotation,

  • can we add an alarm on this event ? so we get notified if the healthChecks failed... ?
  • healthChecks requests can be captured ? in other words if a health check failed, can we log it using MessageLogging policy ? (using Graylog via UDP)

No, Apigee does not send alerts when a target server is removed or added from rotation.

Healthchecks cannot be logged in the current Apigee.

This stuff can be done in the next-gen Apigee.

@Dino-at-Google @Denis Kalitviansky,

Thanks for your response.

I am facing a challenges here, please help me ,

I have a proxy called "access" . under "access" proxy , multiple flow names login,resetpassword,createPassword with different endpoint and one target server. So please suggest, how can I configure HealthMonitor only on login flow not other flows in that proxy. Please suggest.

Hi @Dino-at-Google ,

As per the link you suggested , I added the below code in my proxy target , but looks like its not working.

As per my understanding in the below code , if I am getting http status code either 500 or 503 or 504 from target more than 2 times, then its count as maxfailures is 2.

If its yes its 2 , then as per the HealthMonitor code , my proxy has to be un-deploy and once the target is up , then proxy should be re-deploy with responseCode 200.

If its NO, then please send me the code snippet for correct implementation . My requirement mentioned above in the post.

Please help me.

<LoadBalancer>

<Server name="XXXXXX"/>

<MaxFailures>2</MaxFailures>

<ServerUnhealthyResponse>

<ResponseCode>503</ResponseCode>

<ResponseCode>504</ResponseCode>

<ResponseCode>500</ResponseCode>

</ServerUnhealthyResponse>

</LoadBalancer>

<Path>{targetpath}</Path>

<HealthMonitor>

<IsEnabled>true</IsEnabled>

<IntervalInSec>5</IntervalInSec>

<HTTPMonitor>

<Request>

<ConnectTimeoutInSec>10</ConnectTimeoutInSec>

<SocketReadTimeoutInSec>30</SocketReadTimeoutInSec>

<Port>80</Port>

<Verb>GET</Verb>

<Path>{targetpath}</Path>

</Request>

<SuccessResponse>

<ResponseCode>200</ResponseCode>

<Header name="ImOK">YourOK</Header>

</SuccessResponse>

</HTTPMonitor>

</HealthMonitor>

</HTTPTargetConnection>

Hi @Dino-at-Google... any help on this.

Hi @Dino-at-Google... any help on this.