NumberOfMessagesSent和NumberOfMessagesReceived amazon sqs whith节点

时间:2014-07-04 16:32:35

标签: node.js amazon-sqs

我正在尝试从队列中获取消息总数,但可用属性是

var params = {
  QueueUrl: 'STRING_VALUE', // required
  AttributeNames: [
    'Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy',
    // ... more items ...
  ]
};
sqs.getQueueAttributes(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

如何获得NumberOfMessagesSent和NumberOfMessagesReceived?

1 个答案:

答案 0 :(得分:0)

获取“发送的消息数”而不是“收到的消息数”是没有意义的,因为这些是在您未提供的时间跨度内发生的计数。

然而,

SQS会将指标记录到云观察,您可以获取图表并设置警报。您可以使用这两个指标。以下是文档的链接:http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/MonitorSQSwithCloudWatch.html