简体   繁体   English

过滤 cloudwatch 警报在 SNS 主题上发布的消息以接收 email 通知

[英]Filter messages published by cloudwatch alarms on an SNS topic to receive email notifications

Problem Statement: We are using an SNS topic that is shared through enterprise for different project and it has to be that way, but with everyone using that SNS topic in cloudwatch alarms we get email notifications for all the alarms which we dont want, we want to receive the notifications for just our alarms, the solution could be to add a filter on the subscription but the message coming from cloudwatch alarm doesn't have any message attributes on which we can put the filter.问题陈述:我们正在使用通过企业为不同项目共享的 SNS 主题,它必须是这样,但是每个人都在 cloudwatch 警报中使用该 SNS 主题,我们会收到 email 通知,用于所有我们不想要的警报,我们想要要仅接收警报通知,解决方案可能是在订阅上添加过滤器,但来自 cloudwatch 警报的消息没有任何我们可以放置过滤器的消息属性。 Can anyone please suggest a solution for the problem or let me know if there is a way to add the custom message attributes based on which we can filter.任何人都可以为问题提出解决方案,或者让我知道是否有办法添加自定义消息属性,我们可以根据这些属性进行过滤。

It is not possible to filter messages that come from CloudWatch.无法过滤来自 CloudWatch 的消息。 I had the same issue recently.我最近有同样的问题。 In order to filter messages in SNS the topic, it must have appropriate Message Attributes.为了过滤 SNS 主题中的消息,它必须具有适当的消息属性。

What you can do is this:你可以做的是:

  • Create Lambda function (give it permission to send messages to the SNS topic)创建 Lambda function(授予它向 SNS 主题发送消息的权限)
  • Point your CloudWatch alarms to send an alarm to the Lambda function将您的 CloudWatch 警报指向 Lambda function
  • In your Lambda function write the parser that would recognize for which project the message is supposed to be在您的 Lambda function 中编写解析器,该解析器将识别消息应该是哪个项目
  • From the Lambda function publish a message to the SNS topic and add a Message Attribute that you can use in SNS for filtering从 Lambda function 向 SNS 主题发布消息并添加可在 SNS 中用于过滤的消息属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM