我有一个社交网络主题,它有两个订阅,一个是页面职责API,另一个是pagerdutyEmail。我想使用该主题的订阅过滤策略从pagerduty电子邮件订阅中排除警报。
我不确定应该如何排除它,筛选策略是否有like选项
我试着使用下面的,但不起作用。
"AlarmArn": [
{
"prefix": "arn:aws:cloudwatch"
}
]
}发布于 2021-01-13 16:00:36
我认为Subscription filter policy不会允许您根据警报ARN或任何其他在Cloudwatch JSON有效负载中发送的元数据来过滤Cloudwatch警报。
过滤策略要求发送到SNS主题的有效负载中有一个MessageAttributes字段,该字段应包含一些属性,您希望根据这些属性添加过滤策略以过滤通知。
Cloudwatch告警发送的JSON负载不包含这些属性,如下面的示例负载所示:
{
"Type": "Notification",
"MessageId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"TopicArn": "arn:aws:sns:eu-west-1:000000000000:cloudwatch-alarms",
"Subject": "ALARM: \"Example alarm name\" in EU - Ireland",
"Message": "{\"AlarmName\":\"Example alarm name\",\"AlarmDescription\":\"Example alarm description.\",\"AWSAccountId\":\"000000000000\",\"NewStateValue\":\"ALARM\",\"NewStateReason\":\"Threshold Crossed: 1 datapoint (10.0) was greater than or equal to the threshold (1.0).\",\"StateChangeTime\":\"2017-01-12T16:30:42.236+0000\",\"Region\":\"EU - Ireland\",\"OldStateValue\":\"OK\",\"Trigger\":{\"MetricName\":\"DeliveryErrors\",\"Namespace\":\"ExampleNamespace\",\"Statistic\":\"SUM\",\"Unit\":null,\"Dimensions\":[],\"Period\":300,\"EvaluationPeriods\":1,\"ComparisonOperator\":\"GreaterThanOrEqualToThreshold\",\"Threshold\":1.0}}",
"Timestamp": "2017-01-12T16:30:42.318Z",
"SignatureVersion": "1",
"Signature": "Cg==",
"SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.pem",
"UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:000000000000:cloudwatch-alarms:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}我已经使用Cloudwatch有效负载中的一个键-值对测试了一个过滤策略,但它不适用于我。
参考单据:
https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html
您可能需要使用首选的客户端库编写Lambda函数,并使用Pagerduty Events API来解决问题。
请参阅:
https://developer.pagerduty.com/docs/tools-libraries/client-libraries/ https://developer.pagerduty.com/docs/events-api-v2/trigger-events/
发布于 2020-11-19 04:16:32
上面的筛选器实际上将消息与前缀为arn:was:cloudwatch的AlarmArn进行匹配。
您可以尝试使用anything-but命令。
"AlarmArn": [{
"anything-but": [{
"prefix": "arn.aws.cloudwatch"
}]
}]有关更多信息,请参阅https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html
https://stackoverflow.com/questions/64897992
复制相似问题