google-cloud-platformgoogle-cloud-pubsub

pubsub trigger alert if sent message count is zero


I have a pubsub topic for bucket notification of object finalize. So, whenever a new file is added in the bucket, the subscriber receives the filename in bucket and code acknowledges the message after working with that file in k8s app.

I am creating the alert policy for two cases:

  1. If the app is not able to ack() the message. (To check if there is issue in code or file)
  2. If the files does not arrive in bucket. (atleast 1 file should be arriving in bucket in 30 minutes)

For case 1, I was able to get alert by using metric pubsub.googleapis.com/subscription/backlog_bytes with minimum threshold of N Bytes in X hours.

For case 2, I am not sure which metric to use. I tried pubsub.googleapis.com/subscription/sent_message_count. It only works when there is actually files added in bucket. The metric is not available when no files are added in bucket in a certain time interval. But I really want to check if the bucket is receiving at least 1 file in 30 minutes. How can I achieve this?


Solution

  • You can set up a an alert on metric absence. Instead of the subscription metric, it might be better to set it up on the topic metric for publish message operations, topic/send_request_count:

    Metrics UI