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

Get amount undelivered messages in the subscription

Hello all,

Could you please suggest a way to get a number of "undelivered messages" in the Pub/Sub in the specific subscription_id via API without consuming messages?

Ideally using some Java library /client.

0 1 852
1 REPLY 1

Check out the Monitoring Java client library.

The metric you are looking for is subscription/num_undelivered_messages.  

Note that if you are trying to build an auto scaler, GKE and Compute Engine managed instance groups already have this functionality built in.  So does Dataflow and, likely, anything you use with a push subscription (Functions, Cloud Run, App Engine).