add alarms on management queues
authorJustin Wind <j.wind@partner.samsung.com>
Thu, 14 Sep 2017 20:36:11 +0000 (13:36 -0700)
committerJustin Wind <j.wind@partner.samsung.com>
Thu, 14 Sep 2017 20:36:11 +0000 (13:36 -0700)
infrastructure/modules/management-stack/alarms.tf [new file with mode: 0644]

diff --git a/infrastructure/modules/management-stack/alarms.tf b/infrastructure/modules/management-stack/alarms.tf
new file mode 100644 (file)
index 0000000..c278d19
--- /dev/null
@@ -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}"]
+}