Google PubSub - Counting messages in topic

痞子三分冷 提交于 2019-11-27 02:38:37

问题


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:

  1. Navigate from GCloud Admin Console to: Monitoring

  1. This opens a new window with separate Stackdriver console
  2. Navigate in Stackdriver: Dashboards > Create Dashboard

  1. Click the Add Chart button top-right of dashboard screen

  1. In the input box, type num_undelivered_messages and then SAVE



来源:https://stackoverflow.com/questions/35475082/google-pubsub-counting-messages-in-topic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!