使用 SNS 电子邮件警报为 Elastic Beanstalk 创建多个 Cloudwatch 警报
Create Multiple Cloudwatch Alarms for Elastic Beanstalk with SNS Email Alerts
因此,我一直在网上阅读所有内容,试图让我的正常运行的 Elastic Beanstalk 应用程序在指标出现问题时向我发送电子邮件。
我知道我可以通过控制台执行此操作,但我想要一种可以自动用于多个部署的可配置方法。
到目前为止我有这个(查看编辑):
Resources:
AWSCloudWatch:
Type: "AWS::CloudWatch::Alarm"
Properties:
ActionsEnabled: true
AlarmActions: ""
AlarmDescription: "Traffic spike app over threshold"
AlarmName: "APP CPU Over 70%"
ComparisonOperator: GreaterThanOrEqualToThreshold
EvaluationPeriods: 5
MetricName: CPUUtilization
Namespace: Environment Health
Period: 60
Statistic: Maximum
Threshold: 70
Unit: Percent
如何配置多个警报(环境健康监控器、cpu 监控器、延迟监控器)并让它们向我发送电子邮件?
编辑:上面的代码创建了一个与 ELB 无关的警报。它不会出现在控制台上,而是在一个完全独立的区域中创建。 :(
除了警报之外,您还需要进一步定义事件路由到的 SNS 主题。
之后,您可以定义电子邮件订阅,它将接收那些 Cloudwatch 警报。
这里有一个示例 CloudFormation 模板:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
AlarmTopic:
Type: AWS::SNS::Topic
Alarm:
Type: AWS::CloudWatch::Alarm
Properties:
ActionsEnabled: true
AlarmActions:
- Ref: AlarmTopic
AlarmDescription: "Traffic spike app over threshold"
AlarmName: "APP CPU Over 70%"
ComparisonOperator: GreaterThanOrEqualToThreshold
EvaluationPeriods: 5
MetricName: CPUUtilization
Namespace: Environment Health
Period: 60
Statistic: Maximum
Threshold: 70
Unit: Percent
TopicSubscription:
Type: AWS::SNS::Subscription
Properties:
Endpoint: "email@example.com"
Protocol: Email
TopicArn:
Ref: AlarmTopic
因此,我一直在网上阅读所有内容,试图让我的正常运行的 Elastic Beanstalk 应用程序在指标出现问题时向我发送电子邮件。
我知道我可以通过控制台执行此操作,但我想要一种可以自动用于多个部署的可配置方法。
到目前为止我有这个(查看编辑):
Resources:
AWSCloudWatch:
Type: "AWS::CloudWatch::Alarm"
Properties:
ActionsEnabled: true
AlarmActions: ""
AlarmDescription: "Traffic spike app over threshold"
AlarmName: "APP CPU Over 70%"
ComparisonOperator: GreaterThanOrEqualToThreshold
EvaluationPeriods: 5
MetricName: CPUUtilization
Namespace: Environment Health
Period: 60
Statistic: Maximum
Threshold: 70
Unit: Percent
如何配置多个警报(环境健康监控器、cpu 监控器、延迟监控器)并让它们向我发送电子邮件?
编辑:上面的代码创建了一个与 ELB 无关的警报。它不会出现在控制台上,而是在一个完全独立的区域中创建。 :(
除了警报之外,您还需要进一步定义事件路由到的 SNS 主题。
之后,您可以定义电子邮件订阅,它将接收那些 Cloudwatch 警报。
这里有一个示例 CloudFormation 模板:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
AlarmTopic:
Type: AWS::SNS::Topic
Alarm:
Type: AWS::CloudWatch::Alarm
Properties:
ActionsEnabled: true
AlarmActions:
- Ref: AlarmTopic
AlarmDescription: "Traffic spike app over threshold"
AlarmName: "APP CPU Over 70%"
ComparisonOperator: GreaterThanOrEqualToThreshold
EvaluationPeriods: 5
MetricName: CPUUtilization
Namespace: Environment Health
Period: 60
Statistic: Maximum
Threshold: 70
Unit: Percent
TopicSubscription:
Type: AWS::SNS::Subscription
Properties:
Endpoint: "email@example.com"
Protocol: Email
TopicArn:
Ref: AlarmTopic