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}"] }
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.
2.1m questions
2.1m answers
60 comments
57.0k users