Apigee HealthMonitor for Clould Run target using GoogleIdToken always returning 503s

I am trying to configure a fallback to my Apigee proxy target definition, but the health checks only return 403. The target is a Cloud Run that requires authentication (done via GoogleIDToken), and exposes a /health endpoint.

Here’s what I see in the Cloud Run logs:“The request was not authenticated. Either allow unauthenticated invocations or set the proper Authorization header. Read more at Authentication overview  |  Cloud Run Documentation  |  Google Cloud Additional troubleshooting documentation can be found at: Troubleshoot Cloud Run issues  |  Cloud Run Documentation  |  Google Cloud

For monitoring purposes, I added /health as an endpoint in my proxy, and I can successfully call it from Postman. But when Apigee tries to call it as part of the HealthMonitor configuration in the target definition, it gets a 403 back.

Here’s the definition of the target:

<TargetEndpoint name="default">
  <HTTPTargetConnection>
    <LoadBalancer>
      <Algorithm>RoundRobin</Algorithm>
      <Server name="server1" />
      <Server name="server2">
        <IsFallback>true</IsFallback>
      </Server>
      <MaxFailures>5</MaxFailures>
      <ServerUnhealthyResponse>
          <ResponseCode>500</ResponseCode>
          <ResponseCode>502</ResponseCode>
          <ResponseCode>503</ResponseCode>
      </ServerUnhealthyResponse>
    </LoadBalancer>
    <HealthMonitor>
      <IsEnabled>true</IsEnabled>
      <IntervalInSec>5</IntervalInSec>
      <HTTPMonitor>
        <Request>
          <UseTargetServerSSLInfo>true</UseTargetServerSSLInfo>
          <ConnectTimeoutInSec>10</ConnectTimeoutInSec>
          <SocketReadTimeoutInSec>30</SocketReadTimeoutInSec>
          <Port>443</Port>
          <Verb>GET</Verb>
          <Path>/health</Path>
          <IsSSL>true</IsSSL>
        </Request>
        <SuccessResponse>
          <ResponseCode>200</ResponseCode>
        </SuccessResponse>
      </HTTPMonitor>
    </HealthMonitor>
    <Authentication>
      <GoogleIDToken>
        <Audience useTargetUrl="true"/>
      </GoogleIDToken>
    </Authentication>
  </HTTPTargetConnection>
</TargetEndpoint>

So it seems the GoogleIDToken is not being applied to the health check (whereas it is used in my /health endpoint calls and thus works).

What could be the issue? Am I overconfiguring the HealthMonitor? In the example and other posts here I saw it defined without IsSSL and UseTargetServerSSLInfo. I also did not include the Basic Authorization header mentioned in the documentation.

Gemini suggested adding the tag “IncludeInHealthCheck“ inside the GoogleIDToken tag, but I think it is hallucinating, as I did not find a mention of that anywhere else.

Guidance is much appreciated

Welcome to the Apigee community! We’ve seen that your question hasn’t gotten a response yet. We’ll keep checking in on this thread and encourage other members to share their thoughts.

You have a few things to consider:

  • The HTTPMonitor element doesn’t support message templates or Google Authentication, therefore you can’t dynamically inject credentials into the health check http request.
  • Cloud Run already provides comprehensive health check support, with startup and liveness probes. Adding a health check in Apigee for Cloud Run services would be duplicative.
  • You could instead use a TCP monitor in Apigee, however, it wouldn’t check the health status of the application. Instead, it would provide an option to maintain the service up an running in case of minimal capacity settings (scale down to zero). Even though this is technically possible, I don’t see much value on implementing it.

Hope this helps.

Thanks for the reply and the links! If I understood it well, there is no simple way to set a fallback server in Apigee if the Cloud Run requires authentication, is that correct?

My goal was to have a cross-region fallback option for my proxies. I.e., if all is well, the Cloud Run isntance in the same region is always called, but if the latter is down, then the instance in another region would be called.

My understanding is that without health monitoring in Apigee, I could set a fallback, but the original server(s) would not be reinstated in the rotation after failures, which would not be desirable.