我正在尝试在 SQS 有 50 多条可见消息时创建警报。不幸的是,我从 terraform apply 中收到以下错误。
Error: Creating metric alarm failed: ValidationError: Period (10) not supported
我在 terraform.io 中寻找值限制 => https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm
以及 aws 文档 -> https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html
我的地形如下
resource "aws_cloudwatch_metric_alarm" "aggregator-threshold-ceiling-alarm" {
count = var.tagging_environment == "int" ? 1 : 0
alarm_name = "aggregator-queue-depth-ceiling-alarm"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "ApproximateNumberOfMessagesVisible"
namespace = "AWS/SQS"
period = "10"
statistic = "Maximum"
threshold = "50"
treat_missing_data = "notBreaching"
dimensions = {
QueueName = "${module.sqs_client-comm-aggregator.main-queue-name}"
}
alarm_description = "This metric monitors queue depth and scales up or down accordingly."
alarm_actions = ["${module.sns_cx-clientcomm-load-indicator-lambda-aggregator.topic_arn}"]
}
答案 0 :(得分:2)
我的猜测是 您的 Amazon SQS 队列的 CloudWatch 指标会自动收集并每隔一分钟推送到 CloudWatch。 https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-monitoring-using-cloudwatch.html
对于周期:只有您定义的存储分辨率为 1 秒的自定义指标支持子分钟周期。 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic
尝试将期间设置为 60。