Three causes behind one alarm#
The alarm is usually on subscription/num_undelivered_messages, the number of unacknowledged messages in a subscription, or on subscription/oldest_unacked_message_age, the age in seconds of the oldest of them. Google recommends the regional versions, subscription/num_unacked_messages_by_region and subscription/oldest_unacked_message_age_by_region, because the global ones show a gap when one region is unavailable. Pub/Sub metrics · Monitor Pub/Sub
Both rise when:
- Subscribers are not pulling. The subscriber deployment is down or scaled to zero, its streams are suspended, or it subscribes to a different subscription than the one that has the backlog.
- Subscribers pull but do not acknowledge. Messages are delivered, processing fails or takes longer than the ack deadline, and Pub/Sub redelivers them. Nacks have the same effect, and the documentation warns that a nacked message may be redelivered before new ones. Troubleshoot pull subscriptions
- Subscribers acknowledge, but too slowly. Every message is eventually acked, but the ack rate is below the publish rate, often because each message waits on a dependency that slowed down.
A fourth shape is narrower: a small, steady backlog with a growing oldest age. Google's monitoring guide reads that as a few messages that cannot be processed, which usually crash or fail the subscriber each time. Monitor Pub/Sub
Why they look alike#
The backlog counts unacknowledged messages. A message that was never sent to a subscriber and one that was sent ten times and never acked count the same. The oldest age rises in each case too, since nothing removes the oldest message until someone acks it.
The delivery-side metrics separate them. subscription/sent_message_count counts messages Pub/Sub sent to subscriber clients, subscription/ack_message_count counts messages acknowledged, subscription/expired_ack_deadlines_count counts messages whose ack deadline expired while outstanding to a subscriber, and subscription/nack_requests counts nacks. For StreamingPull, subscription/open_streaming_pulls counts open streams by status, including suspended_client_flow_controlled when the client's flow control stopped delivery and suspended_subscriber_quota_exceeded at a throughput quota. Pub/Sub metrics
Read the subscription and its metrics#
Start with the subscription's settings. gcloud pubsub subscriptions describe is read-only and returns the ack deadline, retention, dead-letter and retry policies, push configuration and state. gcloud pubsub subscriptions describe · Subscription resource
gcloud pubsub subscriptions describe SUBSCRIPTION --project PROJECT \
--format 'yaml(name,topic,ackDeadlineSeconds,messageRetentionDuration,deadLetterPolicy,retryPolicy,pushConfig,state)'
The ack deadline defaults to 10 seconds and can be set from 10 to 600 seconds. High-level client libraries extend deadlines automatically with modify-ack-deadline requests, by default for up to an hour, so the subscription's value is only the starting point. Subscription properties · Lease management
Then read the delivery metrics in Metrics Explorer, or through the Cloud Monitoring API's timeSeries.list, which is a read. Metric types take the prefix pubsub.googleapis.com/, and the subscription is the subscription_id label of the pubsub_subscription resource. Run it once per metric: sent_message_count, ack_message_count, expired_ack_deadlines_count, nack_requests and open_streaming_pulls. timeSeries.list · Reading metric data · Monitored resources
curl -s -G -H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://monitoring.googleapis.com/v3/projects/PROJECT/timeSeries" \
--data-urlencode 'filter=metric.type="pubsub.googleapis.com/subscription/sent_message_count" AND resource.labels.subscription_id="SUBSCRIPTION"' \
--data-urlencode 'interval.startTime=2026-11-23T13:00:00Z' \
--data-urlencode 'interval.endTime=2026-11-23T15:00:00Z' \
--data-urlencode 'view=FULL'
The backlog metrics are sampled every 60 seconds and can take up to 120 seconds to appear; the delivery counters up to four to six minutes. Leave that much at the end of your window before you read a drop as real. Pub/Sub metrics
Do not pull from the subscription with gcloud pubsub subscriptions pull to look at messages. It changes state: a pull delivers messages to you instead of the subscriber, --auto-ack acknowledges them so they leave the subscription, and without it they stay outstanding until their ack deadline passes. gcloud pubsub subscriptions pull
Read the pattern#
| Sent | Acked | Expired deadlines or nacks | Points to |
|---|---|---|---|
| Near zero | Near zero | Near zero | Subscribers not pulling |
| High, above publish rate | Low | High | Pulling, not acking |
| Steady | Steady, below publish rate | Low | Acking too slowly |
| Normal | Normal | A few, repeating | A few stuck messages |
In the first row, check open_streaming_pulls. No open streams means no subscriber is connected. Open streams with a suspended_* status mean subscribers are connected and stopped receiving, for example because their own flow control limits are full of messages they have not acked.
In the second row, sent_message_count well above the publish rate means the same messages are going out again. Look at the subscriber's logs for the error, or at its processing time against the deadline the client library extends to. Expiry rates of 0.1 to 1% can be healthy, per Google's guide; a rate near 100% is not. Monitor Pub/Sub
A worked example: two aging backlogs#
This example is illustrative. The fictional orders service consumes the subscription orders-events-indexer in project example-prod through StreamingPull. Both incidents start with oldest_unacked_message_age_by_region above 600 seconds at 14:10 UTC.
In the first incident, per minute:
| Metric | 13:50 | 14:05 |
|---|---|---|
| Published to the topic | 2,000 | 2,050 |
| sent_message_count | 2,010 | 9,400 |
| ack_message_count | 2,000 | 30 |
| expired_ack_deadlines_count | 5 | 8,900 |
Messages are being sent five times over and almost never acked. The subscriber's logs show each message waiting on a payments API that returns errors after 60 seconds, and the handler neither acks nor nacks. The subscriber is working; its dependency is failing. Follow that dependency: is the latency the client's or the server's?
In the second incident:
| Metric | 13:50 | 14:05 |
|---|---|---|
| Published to the topic | 2,000 | 2,000 |
| sent_message_count | 2,010 | 0 |
| ack_message_count | 2,000 | 0 |
| open_streaming_pulls, status ok | 6 | 0 |
No stream is open and nothing is sent. The subscriber's deployment has no ready replicas since a failed rollout at 14:01. The payments API is fine; the subscriber is gone.
Limits#
When the oldest unacked age exceeds the subscription's message retention duration, Google's monitoring guide lists the result as permanent data loss. Alert well before retention, and read messageRetentionDuration from the describe output now. Monitor Pub/Sub
Push subscriptions do not use pulls or streams; read subscription/push_request_count by response code instead. Dead-letter forwarding counts delivery attempts only approximately, and only when the dead-letter topic and its permissions are set up correctly. Pub/Sub metrics · Dead-letter topics
The metrics show where delivery stops, not why the subscriber failed. For a backlog of the same kind on AWS, see SQS messages that pile up, and for lag on Kafka, stalled or slow consumers. Other dependency failures are in diagnosing runtime dependency failures.
Questions#
What is the difference between num_undelivered_messages and oldest_unacked_message_age?
The first is how many unacknowledged messages the subscription holds. The second is how long the oldest of them has been waiting, in seconds. Both growing together means subscribers are not keeping up; a flat count with a growing age points to a few messages that keep failing.
Why are Pub/Sub messages redelivered when my subscriber is running?
The ack deadline expired before the subscriber acknowledged them, or the subscriber nacked them. Check subscription/expired_ack_deadlines_count and subscription/nack_requests for the subscription.
What is the default Pub/Sub ack deadline?
Ten seconds, configurable from 10 to 600 seconds per subscription. Client libraries extend it per message while they process, up to a configurable maximum.