【问题标题】:aws beanstalk cloudformation add CPUCreditBalance alarmaws beanstalk cloudformation 添加 CPUCreditBalance 警报
【发布时间】:2020-09-29 15:30:49
【问题描述】:

我正在尝试使用 cloudformation 将 CPUCreditBalance AWS::CloudWatch::Alarm 添加到 EBN 应用程序。和图片类似,但使用的是cloudformation

EC2 实例和自动缩放组也是由 cloudformation 创建的。所以我不知道如何让 InscanceId 或 AutoScalingGroupName 将其放置在此代码中

CPUCreditBalanceAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
  AlarmDescription: Warning alarm when EC2 rans out of credit
  MetricName: CPUCreditBalance
  Namespace: AWS/EC2
  Period: 300
  Statistic: Average
  ComparisonOperator: LessThanThreshold
  Threshold: 1
  EvaluationPeriods: 2
  DatapointsToAlarm: 2
  TreatMissingData: breaching
  Dimensions:
    - Name: AutoScalingGroupName
      Value: XXXXXXXX
  AlarmActions:
    - !Ref SnsAlarmWarning

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk amazon-cloudformation monitoring


    【解决方案1】:

    如果您将AWS::AutoScaling::AutoScalingGroup 定义在与警报相同的模板中,则只需使用Ref 即可获取ASG name

      Dimensions:
        - Name: AutoScalingGroupName
          Value: !Ref AWSEBAutoScalingGroup
      AlarmActions:
        - !Ref SnsAlarmWarning
    

    EB创建的资源名称列于:

    【讨论】:

    • 不,AutoScalingGroupName 是在为 beanstalk 运行脚本时自动创建的
    • 或者是否可以将 AWS::AutoScaling::AutoScalingGroup 资源附加到 cloudformation 中的 Beanstalk?
    • @AshrafAlKibsi 是的,我更新了答案。 EB创建的ASG是AWSEBAutoScalingGroup
    • 它不起作用表明 AWSEBAutoScalingGroup 未定义 :(
    • @AshrafAlKibsi 你一定做错了什么。你能提供来自.ebextensionsresources 部分吗?
    猜你喜欢
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 2018-01-24
    • 2021-11-26
    • 1970-01-01
    • 2019-05-09
    • 2019-11-09
    • 2016-05-21
    相关资源
    最近更新 更多