How to Know When a Google Cloud Run Instance Stops Serving Traffic

Viewed 38

I'm aware that Google Cloud Run will send SIGTERM when it's actually shutting an instance down, but what I need is to identify when an instance of a container is no longer serving traffic, since they can continue to run for 15 minutes to an hour after that.

Is that possible?

1 Answers

From my experience, using Cloud Logging or Cloud Monitoring API could allow to get this information, for example in cloud logging getting the last requests using the request below:

resource.type = "cloud_run_revision"
resource.labels.service_name = "backend"
resource.labels.location = "europe-west3"
httpRequest:*

You can use the gcloud cli(gcloud logging read) or the console

Related