如何设置 cloudwatch 警报,该警报应在重试 SNS 主题消息或死信队列中有条目时触发?
AWS 控制台设置或 cloudformation 文档应该会有帮助。
我正在尝试使用 cloudformation 进行设置。但我需要一些文件作为创建警报并将其与 DLQ/SNS 重试链接的文档。感谢任何文档或帮助。
我还没有配置SNS DLQ,但我为SQS和DLQ配置了。
TheDLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: the_queue_dlq
TheQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: the_queue
RedrivePolicy:
deadLetterTargetArn: !GetAtt TheDLQ.Arn
maxReceiveCount: 3
然后您可以创建由 DLQ 中的任何项目触发的警报
TheDlqAlarm: {
Type: "AWS::CloudWatch::Alarm",
Properties: {
AlarmName: `TheDlqAlarm`,
AlarmActions: ...,
TreatMissingData: missing,
EvaluationPeriods: 1,
DatapointsToAlarm: 1,
Period: 1,
Namespace: "AWS/SQS",
MetricName: "ApproximateNumberOfMessagesVisible",
Dimensions: [{ Name: "QueueName", Value: "the_queue_dlq" }],
Statistic: "Sum",
ComparisonOperator: "GreaterThanThreshold",
Threshold: 0,
},
},