没有为SQS指标“ NumberOfMessagesReceived”触发AWS CloudWatch警报

时间:2018-12-14 15:19:29

标签: amazon-web-services amazon-sqs amazon-cloudwatch amazon-cloudwatch-metrics

如果邮件发送到SQS,我试图触发警报。但是,我看到CloudWatch指标表明有消息但没有触发警报。

警报当前也处于INSUFFICIENT_DATA状态。为了进行测试,我正在通过boto3客户端发送消息。

下面是我的SQSCloudWatch警报的CloudFormation模板

QueueMessageAlarm:
Type: AWS::CloudWatch::Alarm
Condition: AlarmsEnabled
Properties:
  AlarmDescription: "Alarm if queue message is greater than 0"
  AlarmActions:
    - !Ref SampleNotificationTopic
  Namespace: "AWS/SQS"
  MetricName: "NumberOfMessagesReceived"
  Statistic: "Sum"
  Period: "900"
  EvaluationPeriods: "1"
  Threshold: "0"
  ComparisonOperator: "GreaterThanThreshold"
  Dimensions:
    - Name: "QueueName"
    - Value:
        Fn::GetAtt:
          - "KinesisStreamFileQueue"
          - "QueueName"

KinesisStreamFileQueue:
  Type: AWS::SQS::Queue
  Properties:
    QueueName: "StreamQueue"

2 个答案:

答案 0 :(得分:0)

使用ApproximateNumberOfMessagesVisible指标而不是任何“已接收”指标。

使用“已接收”度量标准的缺点是,除非您不断接收消息,否则您很可能会陷入INSUFFICIENT_DATA中,从而导致警报问题。

答案 1 :(得分:0)

我通过更改警报资源的➜ ~ curl -I https://ddl.oxidepolska.pl/1544820059040-lootconfig.zip HTTP/2 200 server: nginx date: Fri, 14 Dec 2018 21:54:56 GMT content-type: application/zip content-length: 7138 last-modified: Fri, 14 Dec 2018 20:40:59 GMT etag: "5c14155b-1be2" accept-ranges: bytes Dimensions来解决问题。该资源需要引用队列的properties,并且先前已经获取了队列的arn

url