Skip to content

Commit ea57c65

Browse files
authored
VED-972: Slack Alerts for Id and redis Sync (#1079)
* slack alerting for nhs number change and permission authentication
1 parent e031bb7 commit ea57c65

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

infrastructure/instance/id_sync_lambda.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,38 @@ resource "aws_cloudwatch_log_group" "id_sync_log_group" {
309309
retention_in_days = 30
310310
}
311311

312+
resource "aws_cloudwatch_log_metric_filter" "id_sync_error_logs" {
313+
count = var.error_alarm_notifications_enabled ? 1 : 0
314+
315+
name = "${local.short_prefix}-IdSyncErrorLogsFilter"
316+
pattern = "%\\[ERROR\\]%"
317+
log_group_name = aws_cloudwatch_log_group.id_sync_log_group.name
318+
319+
metric_transformation {
320+
name = "${local.short_prefix}-IdSyncErrorLogs"
321+
namespace = "${local.short_prefix}-IdSyncLambda"
322+
value = "1"
323+
}
324+
}
325+
326+
resource "aws_cloudwatch_metric_alarm" "id_sync_error_alarm" {
327+
count = var.error_alarm_notifications_enabled ? 1 : 0
328+
329+
alarm_name = "${local.short_prefix}-id-sync-lambda-error"
330+
comparison_operator = "GreaterThanOrEqualToThreshold"
331+
evaluation_periods = 1
332+
metric_name = "${local.short_prefix}-IdSyncErrorLogs"
333+
namespace = "${local.short_prefix}-IdSyncLambda"
334+
period = 120
335+
statistic = "Sum"
336+
threshold = 1
337+
alarm_description = "This sets off an alarm for any error logs found in the id sync (nhs number change) Lambda function"
338+
alarm_actions = [data.aws_sns_topic.imms_system_alert_errors.arn]
339+
treat_missing_data = "notBreaching"
340+
}
341+
342+
343+
312344
# delete config_lambda_notification / new_s3_invoke_permission - not required; duplicate
313345

314346
# NEW

infrastructure/instance/redis_sync_lambda.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,36 @@ resource "aws_cloudwatch_log_group" "redis_sync_log_group" {
253253
retention_in_days = 30
254254
}
255255

256+
resource "aws_cloudwatch_log_metric_filter" "redis_sync_error_logs" {
257+
count = var.error_alarm_notifications_enabled ? 1 : 0
258+
259+
name = "${local.short_prefix}-RedisSyncErrorLogsFilter"
260+
pattern = "%\\[ERROR\\]%"
261+
log_group_name = aws_cloudwatch_log_group.redis_sync_log_group.name
262+
263+
metric_transformation {
264+
name = "${local.short_prefix}-RedisSyncErrorLogs"
265+
namespace = "${local.short_prefix}-RedisSyncLambda"
266+
value = "1"
267+
}
268+
}
269+
270+
resource "aws_cloudwatch_metric_alarm" "redis_sync_error_alarm" {
271+
count = var.error_alarm_notifications_enabled ? 1 : 0
272+
273+
alarm_name = "${local.short_prefix}-id-sync-lambda-error"
274+
comparison_operator = "GreaterThanOrEqualToThreshold"
275+
evaluation_periods = 1
276+
metric_name = "${local.short_prefix}-RedisSyncErrorLogs"
277+
namespace = "${local.short_prefix}-RedisSyncLambda"
278+
period = 120
279+
statistic = "Sum"
280+
threshold = 1
281+
alarm_description = "This sets off an alarm for any error logs found in the redis sync Lambda function"
282+
alarm_actions = [data.aws_sns_topic.imms_system_alert_errors.arn]
283+
treat_missing_data = "notBreaching"
284+
}
285+
256286
# S3 Bucket notification to trigger Lambda function for config bucket
257287
resource "aws_s3_bucket_notification" "config_lambda_notification" {
258288

0 commit comments

Comments
 (0)