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:
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?
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
: