diff --git a/services/terraform/remote/aws_cloudwatch_alarms.tf b/services/terraform/remote/aws_cloudwatch_alarms.tf --- a/services/terraform/remote/aws_cloudwatch_alarms.tf +++ b/services/terraform/remote/aws_cloudwatch_alarms.tf @@ -1,6 +1,15 @@ locals { lambda_error_subscribed_email = "error-reports@comm.app" lambda_error_threshold = "2" + + identity_error_patterns = { + Search = { name = "Search", pattern = "Search Error" }, + Sync = { name = "Sync", pattern = "Sync Error" }, + Database = { name = "DB", pattern = "*DB Error" }, + GrpcServices = { name = "GrpcServices", pattern = "gRPC Services Error" }, + Siwe = { name = "Siwe", pattern = "SIWE Error" }, + Tunnelbroker = { name = "Tunnelbroker", pattern = "Tunnelbroker Error" } + } } resource "aws_sns_topic" "lambda_alarm_topic" { @@ -29,3 +38,17 @@ FunctionName = module.shared.search_index_lambda.function_name } } + +resource "aws_cloudwatch_log_metric_filter" "identity_error_filters" { + for_each = local.identity_error_patterns + + name = "Identity${each.value.name}ErrorCount" + pattern = "{ $.level = \"ERROR\" && $.fields.errorType = \"${each.value.pattern}\" }" + log_group_name = "/ecs/identity-service-task-def" + + metric_transformation { + name = "Identity${each.value.name}ErrorCount" + namespace = "IdentityServiceMetricFilters" + value = "1" + } +}