File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -178,3 +178,34 @@ resource "aws_cloudwatch_log_group" "delta_lambda" {
178178 name = " /aws/lambda/${ local . short_prefix } -${ local . function_name } "
179179 retention_in_days = 30
180180}
181+
182+
183+ resource "aws_cloudwatch_log_metric_filter" "delta_error_logs" {
184+ count = var. error_alarm_notifications_enabled ? 1 : 0
185+
186+ name = " ${ local . short_prefix } -DeltaErrorLogsFilter"
187+ pattern = " %\\ [ERROR\\ ]%"
188+ log_group_name = aws_cloudwatch_log_group. delta_lambda . name
189+
190+ metric_transformation {
191+ name = " ${ local . short_prefix } -DeltaErrorLogs"
192+ namespace = " ${ local . short_prefix } -DeltaLambda"
193+ value = " 1"
194+ }
195+ }
196+
197+ resource "aws_cloudwatch_metric_alarm" "delta_error_alarm" {
198+ count = var. error_alarm_notifications_enabled ? 1 : 0
199+
200+ alarm_name = " ${ local . short_prefix } -delta-lambda-error"
201+ comparison_operator = " GreaterThanOrEqualToThreshold"
202+ evaluation_periods = 1
203+ metric_name = " ${ local . short_prefix } -DeltaErrorLogs"
204+ namespace = " ${ local . short_prefix } -DeltaLambda"
205+ period = 120
206+ statistic = " Sum"
207+ threshold = 1
208+ alarm_description = " This sets off an alarm for any error logs found in the delta Lambda function"
209+ alarm_actions = [data . aws_sns_topic . batch_processor_errors . arn ]
210+ treat_missing_data = " notBreaching"
211+ }
You can’t perform that action at this time.
0 commit comments