[英]How to create alarm on number of EventBridge Rules breaching a certain threshold?
I have a system that auto creates and deletes CloudWatch Rules but there is a hard limit of 300 rules in every Event Bus.我有一个自动创建和删除 CloudWatch 规则的系统,但每个事件总线都有 300 条规则的硬性限制。 I want to create an alarm that gets triggered whenever a certain number, say 100, is reached.
我想创建一个警报,只要达到某个数字(比如 100)就会触发该警报。 How can I do that using CDK code?
我怎样才能使用 CDK 代码做到这一点?
Create a Lambda function that calls the ListRules API.创建调用ListRules API 的 Lambda 函数。 The Lambda counts the rules.
Lambda 计算规则。 Have EventBridge trigger the Lambda periodically with a scheduled Rule .
让 EventBridge 使用计划规则定期触发Lambda。 If you want an Alarm, your Lambda could write the rule count to CloudWatch as a custom metric and configure an Alarm to monitor it.
如果您想要一个警报,您的 Lambda 可以将规则计数作为自定义指标写入 CloudWatch,并配置一个警报来监控它。 A simpler option is to have the Lambda put an SNS notification to a Topic if the rule count exceeds 100.
一个更简单的选项是让 Lambda 在规则计数超过 100 时向主题发送 SNS 通知。
To recap, the CDK constructs would be: a Lambda Function
, an EventBridge Rule
and a CloudWatch Alarm
(or SNS Topic
and Subscription
).回顾一下,CDK 构造将是:一个 Lambda
Function
、一个 EventBridge Rule
和一个 CloudWatch Alarm
(或 SNS Topic
和Subscription
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.