From 186afd44008b989b18f68d2dabd9a6176bd66694 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Fri, 30 Apr 2021 09:25:12 +0300 Subject: [PATCH] Who watches the watchers? Monitor the monitoring system. --- alarms.tf | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 alarms.tf diff --git a/alarms.tf b/alarms.tf new file mode 100644 index 0000000..b236cde --- /dev/null +++ b/alarms.tf @@ -0,0 +1,41 @@ +resource "aws_cloudwatch_metric_alarm" "invocations" { + count = length(local.function_names) + alarm_actions = [local.topic_arn] + actions_enabled = true + alarm_name = "Invocations alarm for ${local.function_names[count.index]}." + comparison_operator = "LessThanThreshold" + evaluation_periods = "1" + insufficient_data_actions = [local.topic_arn] + metric_name = "Invocations" + namespace = "AWS/Lambda" + ok_actions = [local.topic_arn] + period = (var.rate + 1) * 60 + statistic = "Sum" + tags = local.common_tags + threshold = 1 + + dimensions = { + FunctionName = local.function_names[count.index] + } +} + +resource "aws_cloudwatch_metric_alarm" "errors" { + count = length(local.function_names) + alarm_actions = [local.topic_arn] + actions_enabled = true + alarm_name = "Errors alarm for ${local.function_names[count.index]}." + comparison_operator = "GreaterThanThreshold" + evaluation_periods = "1" + insufficient_data_actions = [local.topic_arn] + metric_name = "Errors" + namespace = "AWS/Lambda" + ok_actions = [local.topic_arn] + period = (var.rate + 1) * 60 + statistic = "Sum" + tags = local.common_tags + threshold = 0 + + dimensions = { + FunctionName = local.function_names[count.index] + } +} -- GitLab