trjade
trjade

Reputation: 210

REST API for monitoring undelivered message in google cloud pubsub

I want to implement a service to monitor an undelivered messages and send notification when it reach threshold or process further.

I already look through the Stackdriver. It provide me the monitoring and alert that It only provide the API to get the metricDescriptor but it does not provide an API to get the undelivered message as you can see in Stackdriver Monitoring API.

Is there actually an provided API to get the metrics value?

Upvotes: 3

Views: 1362

Answers (1)

Kamal Aboul-Hosn
Kamal Aboul-Hosn

Reputation: 17216

You can get the values via the projects.timeSeries.list method. You would set the name to projects/<your project>, filter to metric.type = "pubsub.googleapis.com/subscription/num_undelivered_messages", and end time (and if a range of values is desired, the start time as well) to a string representing a time in RFC3339 UTC "Zulu" format, e.g., 2018-10-04T14:00:00Z. If you want to look at a specific subscription, set the filter to metric.type = "pubsub.googleapis.com/subscription/num_undelivered_messages" AND resource.label.subscription_id = "<subscription name>".

The result will be one or more TimeSeries types (depending on whether or not you specified a specific subscription) with the points field including the data points for the specified time range, each of which will have the value's int64Value set to the number of messages that have have not been acknowledged by subscribers.

Upvotes: 6

Related Questions