简体   繁体   English

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

[英]AWS CloudWatch Alarm not triggered for SQS Metrics “NumberOfMessagesReceived”

I am trying to trigger an alarm if message is sent to SQS . 如果消息发送到SQS我试图触发警报。 However, I see that the CloudWatch metrics indicates that there was a message but no alarm is triggered. 但是,我看到CloudWatch指标表明有消息但没有触发警报。

The alarm is currently in INSUFFICIENT_DATA state as well. 警报当前也处于INSUFFICIENT_DATA状态。 For testing, I am sending a message via boto3 client. 为了进行测试,我正在通过boto3客户端发送消息。

Below is my CloudFormation Template for SQS and CloudWatch alarm 以下是我的SQSCloudWatch警报的CloudWatch模板

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"

Use the ApproximateNumberOfMessagesVisible metric instead of any "Received" metric. 使用roximateNumberOfMessagesVisible指标,而不是任何“已接收”指标。

The downside of using "Received" metrics is that unless you're constantly receiving messages, you're likely to get stuck in INSUFFICIENT_DATA , resulting in alarm issues. 使用“已接收”度量标准的不利之处在于,除非您不断接收消息,否则您很可能会陷入INSUFFICIENT_DATA ,从而导致警报问题。

I figured out the issue by changing the Dimensions properties for the alarm resource. 我通过更改警报资源的“ Dimensions properties来解决问题。 The resource needs to refer to the arn of the queue, and it was previously getting the url of it 该资源需要引用队列的arn ,并且之前已获取到它的url

Dimensions:
    - Name: QueueName
      Value: { "Fn::GetAtt": [ "KinesisStreamFileQueue", "QueueName"] }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 适用于SQS的AWS CloudWatch警报消息数量可见 - AWS CloudWatch alarm for SQS Number of Messages Visible 为什么我的 AWS CloudWatch 警报没有被触发? - Why is my AWS CloudWatch alarm not being triggered? 未触发 Amazon Cloudwatch 警报 - Amazon Cloudwatch alarm not triggered 如何找出谁创建了AWS CloudWatch警报/指标? - How to find out who created aws cloudwatch alarm/metrics? 如何生成涉及多个指标的AWS CloudWatch警报 - How to generate AWS CloudWatch Alarm which involves multiple Metrics 实例关闭时触发 AWS Cloudwatch 监控警报 - AWS Cloudwatch monitoring alarm is triggered when instance is off 适用于 RDS 的 AWS cloudwatch 警报 - AWS cloudwatch alarm for RDS 具有SQS的AWS自动扩展和CloudWatch - AWS Autoscaling and CloudWatch with SQS 适用于CloudWatch警报的AWS CloudFormation模板:如何通过ElasticSearch节点而不是整个ElasticSearch集群使用指标来描述警报 - AWS CloudFormation template for CloudWatch alarm: how to describe the alarm with metrics by ElasticSearch node, not by whole ElasticSearch cluster AWS Cloudwatch - 当我尝试为SQS创建警报时,自动调节组未显示 - AWS Cloudwatch - Autoscaling groups are not showing up when I try to create an alarm for SQS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM