How do you access the current message count in a PubSub topic

4,110 views
Skip to first unread message

Mike Sparr

unread,
Sep 12, 2018, 8:21:53 AM9/12/18
to Google Cloud Pub/Sub Discussions
Hello,

I posted similar last week but post didn't appear. I want to know how to tell how many messages are in a PubSub topic. 

In the GCloud admin console it only displays the subscriber count, but nothing about messages. 
In CLI console I can list topics but they don't display message count. 
In Stack Overflow others asked the same question 2 years ago and seems still not resolved. 
In Github there in issue #8 about similar issue and after many months discussion only response was product team would have to add the feature to get message count but no update since last year.

Viewing message count in topics is a basic feature of any queue system, and available in SQS, Kinesis, Kafka, RabbitMQ, etc. I can't believe this wouldn't exist in PubSub. So far the only answer I've found is some monitoring setting for unconsumed messages in Stackdriver but no instructions exactly what to do.  Best I can find??? https://cloud.google.com/monitoring/api/metrics

Is there some documented resource that explains step-by-step how to get the message count in a PubSub topic?

Thanks,

Mike


Alex Mordkovich

unread,
Sep 12, 2018, 12:06:45 PM9/12/18
to mi...@goomzee.com, Google Cloud Pub/Sub Discussions
Hi Mike,
Please see responses inline:

On Wed, Sep 12, 2018 at 8:21 AM Mike Sparr <mi...@goomzee.com> wrote:
Hello,

I posted similar last week but post didn't appear. I want to know how to tell how many messages are in a PubSub topic. 

In the GCloud admin console it only displays the subscriber count, but nothing about messages. 
In CLI console I can list topics but they don't display message count. 
In Stack Overflow others asked the same question 2 years ago and seems still not resolved. 

Could you provide a link to this StackOverflow question?
 
In Github there in issue #8 about similar issue and after many months discussion only response was product team would have to add the feature to get message count but no update since last year.

Could you provide a link to this Github issue?


Viewing message count in topics is a basic feature of any queue system, and available in SQS, Kinesis, Kafka, RabbitMQ, etc. I can't believe this wouldn't exist in PubSub. So far the only answer I've found is some monitoring setting for unconsumed messages in Stackdriver but no instructions exactly what to do.  Best I can find??? https://cloud.google.com/monitoring/api/metrics

As mentioned at https://groups.google.com/forum/#!topic/cloud-pubsub-discuss/KM4Sc-gJqIM, there are Pub/Sub-specific metrics that users can monitor. Instructions for building charts can be found at https://cloud.google.com/monitoring/charts/.

Is there some documented resource that explains step-by-step how to get the message count in a PubSub topic?

Thanks,

Mike


--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/24357840-81a8-490e-a7d4-26fd51d8274a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jean-Baptiste Claramonte

unread,
Sep 21, 2018, 9:38:29 AM9/21/18
to mi...@goomzee.com, cloud-pubs...@googlegroups.com
Hello Mike,

From my understanding of Pub/Sub a topic doesn't store any message, it's an endpoint where you can publish messages. 
You create and attach subscriptions to a topic and each subscription will store a copy of messages sent to the topic. 
Then a client can read messages stored in a subscription.
You can see the messages available in a subscription using the gcloud CLI. For example:

gcloud pubsub subscriptions pull my-subscription

JB

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/24357840-81a8-490e-a7d4-26fd51d8274a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jean-Baptiste Claramonte
Consultant

156 Boulevard Haussmann
75008 Paris, France

+33 (0)6 60 65 25 98

Xebia Xebia Xebia Xebia
Xebia 
SOFTWARE DEVELOPMENT DONE RIGHT
Xebia

Xebia . Blog . Vis Ma Vie . Xebia TV . Xebia Training . Xebia Studio . Xebia Data Factory . Xebia Mobile

Frenchkit


Reply all
Reply to author
Forward
0 new messages