Create CloudWatch alarm on multiple SQS queues

白昼怎懂夜的黑 提交于 2019-12-12 19:25:07

问题


Suppose I have N EC2 instances in auto-scaling group, each of them is polling M SQS queues. How would I create an alarm on cumulative ApproximateNumberOfMessagesVisible across all SQS queues if possible?


回答1:


There is no cumulative count of the visible messages metric available as of now.

Here is how you can solve it,

Create a Lambda/ cron job that can poll the queues, get ApproximateNumberOfMessages on each queue and update the total messages to a custom Cloudwatch Metric.

QueueAttributes:

http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_GetQueueAttributes.html

Custom Cloudwatch Metric:

http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html

You can either create a lambda (serverless) or if you want to server based, you can poll and update total count into a custom cloudwatch metric with cli to AWS cloudwatch.

Once you have have the cloudwatch metric, you can create an alarm based on those numbers.

Hope it helps.



来源:https://stackoverflow.com/questions/46375981/create-cloudwatch-alarm-on-multiple-sqs-queues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!