From 3ab1c9f288caa21c8e630cb29f9bda1d63ba9ad9 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Thu, 14 Sep 2017 13:36:11 -0700 Subject: [PATCH] add alarms on management queues --- .../modules/management-stack/alarms.tf | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 infrastructure/modules/management-stack/alarms.tf 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}"] +} -- 2.45.2