amazon-web-services - 如何将 CloudWatch 警报配置为每 X 分钟评估一次

标签 amazon-web-services amazon-cloudwatch cloudwatch-alarms

我想将 CloudWatch 警报配置为:

  • 对 ApplicationRequestsTotal 指标的最后 30 分钟求和每 30 分钟一次
  • 总和为0时报警

我已将自定义 CloudWatch ApplicationRequestsTotal 指标配置为每 60 秒为我的服务发出一次。

我已将闹钟配置为:

{
    "MetricAlarms": [
        {
            "AlarmName": "radio-silence-alarm",
            "AlarmDescription": "Alarm if 0 or less requests are received for 1 consecutive period(s) of 30 minutes.",
            "ActionsEnabled": true,
            "OKActions": [],
            "InsufficientDataActions": [],
            "MetricName": "ApplicationRequestsTotal",
            "Namespace": "AWS/ElasticBeanstalk",
            "Statistic": "Sum",
            "Dimensions": [
                {
                    "Name": "EnvironmentName",
                    "Value": "service-environment"
                }
            ],
            "Period": 1800,
            "EvaluationPeriods": 1,
            "Threshold": 0.0,
            "ComparisonOperator": "LessThanOrEqualToThreshold",
            "TreatMissingData": "missing"
        }
    ],
    "CompositeAlarms": []
}

我设置了很多这样的闹钟,每个闹钟似乎:

  • 每分钟对 ApplicationRequestsTotal 指标的最后 30 分钟求和一次

例如,此服务在 8:36a 开始获得 0 ApplicationRequestsTotal,而恰好在 9:06a CloudWatch 触发了警报。

CloudWatch Alarm seems to evaluate EVERY minute

上述时间段的aws cloudwatch describe-alarm-history:

{
    "AlarmName": "radio-silence-alarm",
    "AlarmType": "MetricAlarm",
    "Timestamp": "2021-09-29T09:06:37.929000+00:00",
    "HistoryItemType": "StateUpdate",
    "HistorySummary": "Alarm updated from OK to ALARM",
    "HistoryData": "{
       "version":"1.0",
       "oldState":{
          "stateValue":"OK",
          "stateReason":"Threshold Crossed: 1 datapoint [42.0 (22/09/21 08:17:00)] was not less than or equal to the threshold (0.0).",
          "stateReasonData":{
             "version":"1.0",
             "queryDate":"2021-09-22T08:47:37.930+0000",
             "startDate":"2021-09-22T08:17:00.000+0000",
             "statistic":"Sum",
             "period":1800,
             "recentDatapoints":[
                42.0
             ],
             "threshold":0.0,
             "evaluatedDatapoints":[
                {
                   "timestamp":"2021-09-22T08:17:00.000+0000",
                   "sampleCount":30.0,
                   "value":42.0
                }
             ]
          }
       },
       "newState":{
          "stateValue":"ALARM",
          "stateReason":"Threshold Crossed: 1 datapoint [0.0 (29/09/21 08:36:00)] was less than or equal to the threshold (0.0).",
          "stateReasonData":{
             "version":"1.0",
             "queryDate":"2021-09-29T09:06:37.926+0000",
             "startDate":"2021-09-29T08:36:00.000+0000",
             "statistic":"Sum",
             "period":1800,
             "recentDatapoints":[
                0.0
             ],
             "threshold":0.0,
             "evaluatedDatapoints":[
                {
                   "timestamp":"2021-09-29T08:36:00.000+0000",
                   "sampleCount":30.0,
                   "value":0.0
                }
             ]
          }
       }
    }"
}

我哪里配置不正确?

最佳答案

这不是 Amazon CloudWatch 的工作方式。

在 CloudWatch 中创建警报时,您指定:

  • 指标(例如 CPU 利用率,或者可能是发送到 CloudWatch 的自定义指标)
  • 时间段(例如前 30 分钟)
  • 一种聚合方法(例如平均、求和、计数)

例如,如果在过去 30 分钟内超过了指标的平均值,CloudWatch 可以触发警报。这是持续评估为滑动窗口。它查看不同 30 分钟时间段内的指标。

使用您的示例,每当 30 分钟的指标总和为零时,它将持续发送警报。

关于amazon-web-services - 如何将 CloudWatch 警报配置为每 X 分钟评估一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69384768/

相关文章:

amazon-web-services - 此 Auto Scaling 组的服务相关角色尚未可供使用

amazon-web-services - 如何将 S3 存储桶的特定文件夹的内容复制到不同 S3 存储桶的另一个特定文件夹

node.js - 使用 AWS Lambda (nodejs) 获取 twilio 使用数据

amazon-web-services - 如何使用过滤策略从 SNS 主题中排除 cloudwatch 警报?

amazon-web-services - AWS::CloudWatch::Alarm - AWS CloudFormation - 不适用于多个维度

amazon-web-services - 如何在 SQS 消息发送到死信队列时生成警报?

amazon-web-services - 具有有限弹性IP的AWS架构

logging - 使用 slf4j(和 io.symphonia :lambda-logging) in AWS Lambas)登录时,CloudWatch 输出中出现新行问题

amazon-web-services - 亚马逊 RDS : plot number of instances in CloudWatch

amazon-web-services - 过滤 AWS Cloudwatch Lambda 的日志