问题
I've looked over the documentation for Google's PubSub, and also tried looking in Google Cloud Monitoring, but couldn't find any means of figuring out what's the queue size in my topics.
Since I plan on using PubSub for analytics, it's important for me to monitor the queue count, so I could scale up/down the subscriber count.
What am I missing?
回答1:
The metric you want to look at is "undelivered messages." You should be able to set up alerts or charts that monitor this metric in Google Cloud Monitoring under the "Pub/Sub Subscription" resource type. The number of messages that have not yet been acknowledged by subscribers, i.e., queue size, is a per-subscription metric as opposed to a per-topic metric. For info on the metric, see pubsub.googleapis.com/subscription/num_undelivered_messages
in the GCP Metrics List (and others for all of the Pub/Sub metrics available).
回答2:
The answer to your question is "no", there is no feature for PubSub that shows these counts. The way you have to do it is via log event monitoring using Stackdriver (it took me some time to find that out too).
The colloquial answer to this is do the following, step-by-step:
- Navigate from GCloud Admin Console to:
Monitoring
- This opens a new window with separate Stackdriver console
- Navigate in Stackdriver:
Dashboards
>Create Dashboard
- Click the
Add Chart
button top-right of dashboard screen
- In the input box, type
num_undelivered_messages
and thenSAVE
来源:https://stackoverflow.com/questions/35475082/google-pubsub-counting-messages-in-topic