Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

amazon web services - Terraform Apply Failure - Creating metric alarm failed. Period (10) not supported

I'm trying to create an alarm when an SQS has 50+ messages visible. I'm unfortunately getting the following error from terraform apply.

Error: Creating metric alarm failed: ValidationError: Period (10) not supported

I looked for value restrictions in terraform.io => https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm

as well as aws docs -> https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html

My terraform is as follows

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}"]
}
question from:https://stackoverflow.com/questions/66050315/terraform-apply-failure-creating-metric-alarm-failed-period-10-not-supporte

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My guess is CloudWatch metrics for your Amazon SQS queues are automatically collected and pushed to CloudWatch at one-minute intervals. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-monitoring-using-cloudwatch.html

And for period: Only custom metrics that you define with a storage resolution of 1 second support sub-minute periods. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Statistic

Try to set 60 for period.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...