From: Justin Wind Date: Thu, 14 Sep 2017 20:36:11 +0000 (-0700) Subject: add alarms on management queues X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=3ab1c9f288caa21c8e630cb29f9bda1d63ba9ad9;p=awsible add alarms on management queues --- diff --git a/infrastructure/modules/management-stack/alarms.tf b/infrastructure/modules/management-stack/alarms.tf new file mode 100644 index 0000000..c278d19 --- /dev/null +++ b/infrastructure/modules/management-stack/alarms.tf @@ -0,0 +1,31 @@ +resource "aws_cloudwatch_metric_alarm" "unconsumed" { + alarm_name = "${length(var.sqs_events_name) > 0 ? var.sqs_events_name : var.management_service_name}${length(var.sqs_events_name) > 0 ? "" : "-events"}-unconsumed" + alarm_description = "Alert when queue has aging messages." + metric_name = "ApproximateAgeOfOldestMessage" + comparison_operator = "GreaterThanOrEqualToThreshold" + evaluation_periods = 10 + period = 60 + namespace = "AWS/SQS" + statistic = "Maximum" + threshold = 1800 + dimensions { + QueueName = "${length(var.sqs_events_name) > 0 ? var.sqs_events_name : var.management_service_name}${length(var.sqs_events_name) > 0 ? "" : "-events"}" + } + alarm_actions = ["${aws_sns_topic.management-alerts.arn}"] +} + +resource "aws_cloudwatch_metric_alarm" "failures-present" { + alarm_name = "${length(var.sqs_events_name) > 0 ? var.sqs_events_name : var.management_service_name}${length(var.sqs_events_name) > 0 ? "" : "-events"}-failed-present" + alarm_description = "Alert when a message has failed." + metric_name = "ApproximateNumberOfMessagesVisible" + comparison_operator = "GreaterThanOrEqualToThreshold" + evaluation_periods = 2 + period = 60 + namespace = "AWS/SQS" + statistic = "Sum" + threshold = 1 + dimensions { + QueueName = "${length(var.sqs_events_name) > 0 ? var.sqs_events_name : var.management_service_name}${length(var.sqs_events_name) > 0 ? "" : "-events"}-failed" + } + alarm_actions = ["${aws_sns_topic.management-alerts.arn}"] +}