Skip to content

Commit f4a0ca6

Browse files
authored
VED-992: Metrics for mesh backlog (#1098)
* add custom metrics for mesh backlog objects
1 parent e83dcd7 commit f4a0ca6

6 files changed

Lines changed: 40 additions & 0 deletions

File tree

infrastructure/instance/environments/preprod/int-blue/variables.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ immunisation_account_id = "084828561157"
33
dspp_core_account_id = "603871901111"
44
pds_environment = "int"
55
error_alarm_notifications_enabled = true
6+
7+
# mesh no invocation period metric set to 3 days (in seconds) for preprod environment i.e 3 * 24 * 60 * 60
8+
mesh_no_invocation_period_seconds = 259200
69
create_mesh_processor = true
710
has_sub_environment_scope = false

infrastructure/instance/environments/preprod/int-green/variables.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ immunisation_account_id = "084828561157"
33
dspp_core_account_id = "603871901111"
44
pds_environment = "int"
55
error_alarm_notifications_enabled = true
6+
7+
# mesh no invocation period metric set to 3 days (in seconds) for preprod environment i.e 3 * 24 * 60 * 60
8+
mesh_no_invocation_period_seconds = 259200
69
create_mesh_processor = true
710
has_sub_environment_scope = false

infrastructure/instance/environments/prod/blue/variables.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ immunisation_account_id = "664418956997"
33
dspp_core_account_id = "232116723729"
44
pds_environment = "prod"
55
error_alarm_notifications_enabled = true
6+
7+
# mesh no invocation period metric set to 1 day (in seconds) for prod environment i.e 1 * 24 * 60 * 60
8+
mesh_no_invocation_period_seconds = 86400
69
create_mesh_processor = true
710
has_sub_environment_scope = false
811
dspp_kms_key_alias = "nhsd-dspp-core-prod-extended-attributes-gdp-key"

infrastructure/instance/environments/prod/green/variables.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ immunisation_account_id = "664418956997"
33
dspp_core_account_id = "232116723729"
44
pds_environment = "prod"
55
error_alarm_notifications_enabled = true
6+
7+
# mesh no invocation period metric set to 1 day (in seconds) for prod environment i.e 1 * 24 * 60 * 60
8+
mesh_no_invocation_period_seconds = 86400
69
create_mesh_processor = true
710
has_sub_environment_scope = false
811
dspp_kms_key_alias = "nhsd-dspp-core-prod-extended-attributes-gdp-key"

infrastructure/instance/mesh_processor.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,25 @@ resource "aws_cloudwatch_metric_alarm" "mesh_processor_error_alarm" {
288288
alarm_actions = [data.aws_sns_topic.imms_system_alert_errors.arn]
289289
treat_missing_data = "notBreaching"
290290
}
291+
292+
resource "aws_cloudwatch_metric_alarm" "mesh_processor_no_lambda_invocation_alarm" {
293+
count = var.create_mesh_processor && var.error_alarm_notifications_enabled ? 1 : 0
294+
295+
alarm_name = "imms-${local.resource_scope}-mesh-processor-no-lambda-invocation"
296+
alarm_description = "Triggers when the MESH Processor Lambda has no invocations for the configured time window."
297+
298+
metric_name = "Invocations"
299+
namespace = "AWS/Lambda"
300+
statistic = "Sum"
301+
period = var.mesh_no_invocation_period_seconds
302+
303+
evaluation_periods = 1
304+
comparison_operator = "LessThanThreshold"
305+
threshold = 1
306+
treat_missing_data = "breaching"
307+
dimensions = {
308+
FunctionName = aws_lambda_function.mesh_file_converter_lambda[0].function_name
309+
}
310+
311+
alarm_actions = [data.aws_sns_topic.imms_system_alert_errors.arn]
312+
}

infrastructure/instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ variable "pds_environment" {
4040
default = "int"
4141
}
4242

43+
variable "mesh_no_invocation_period_seconds" {
44+
description = "The maximum duration the MESH Processor Lambda can go without being invoked before the no-invocation alarm is triggered."
45+
type = number
46+
default = 300
47+
}
48+
4349
# Remember to switch off in PR envs after testing
4450
variable "error_alarm_notifications_enabled" {
4551
default = true

0 commit comments

Comments
 (0)