Skip to content

Commit 24d8d76

Browse files
[PRM-134-v2] more exploration of custom banding within alarms
1 parent dc2d4db commit 24d8d76

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

infrastructure/lambda-search-patient.tf

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "aws_cloudwatch_metric_alarm" "error_alarm_count_low" {
4646
}
4747
metric_query {
4848
id = "error"
49-
label = "error count for search patient, high if about 4, low if between 1 and 3"
49+
label = "error count for search patient, high if above 7, low if between 1 and 3, med between 4 - 6, high 7+"
5050
return_data = true
5151
expression = "IF(m1 >= 1 AND m1 <= 3, 1, 0)"
5252
}
@@ -69,9 +69,9 @@ resource "aws_cloudwatch_metric_alarm" "error_alarm_count_low" {
6969

7070
resource "aws_cloudwatch_metric_alarm" "error_alarm_count_medium" {
7171
alarm_name = "search_patient_error_count_medium"
72-
alarm_description = "Triggers when search patient lambda error count is between 1 and 3 within 2mins"
72+
alarm_description = "Triggers when search patient lambda error count is between 4 and 6 within 2mins"
7373
comparison_operator = "GreaterThanThreshold"
74-
threshold = 4
74+
threshold = 0
7575
evaluation_periods = 1
7676
alarm_actions = [module.search_patient_alarm_topic.arn]
7777
ok_actions = [module.search_patient_alarm_topic.arn]
@@ -100,28 +100,64 @@ resource "aws_cloudwatch_metric_alarm" "error_alarm_count_medium" {
100100
}
101101
}
102102
}
103+
103104
resource "aws_cloudwatch_metric_alarm" "error_alarm_count_high" {
104105
alarm_name = "search_patient_error_count_high"
105-
alarm_description = "Triggers when search patient lambda error count is above 3 within 2mins"
106+
alarm_description = "Triggers when search patient lambda error count is about 7"
106107
comparison_operator = "GreaterThanThreshold"
108+
threshold = 0
107109
evaluation_periods = 1
108110
alarm_actions = [module.search_patient_alarm_topic.arn]
109111
ok_actions = [module.search_patient_alarm_topic.arn]
110-
threshold = 7
111-
period = 120
112-
dimensions = {
113-
FunctionName = module.search-patient-details-lambda.function_name
114-
}
115-
metric_name = "Errors"
116-
statistic = "Sum"
117-
namespace = "AWS/Lambda"
118112
tags = {
119113
alerting_type = "KPI"
120114
alarm_group = module.search-patient-details-lambda.function_name
121115
}
116+
metric_query {
117+
id = "error"
118+
label = "error count for search patient, high if about 4, low if between 1 and 3"
119+
return_data = true
120+
expression = "IF(m1 >= 7, 1, 0)"
121+
}
122+
123+
metric_query {
124+
id = "m1"
125+
126+
metric {
127+
metric_name = "Errors"
128+
namespace = "AWS/Lambda"
129+
period = 120
130+
stat = "Sum"
131+
dimensions = {
132+
FunctionName = module.search-patient-details-lambda.function_name
133+
}
134+
}
135+
}
122136
}
123137

124138

139+
# resource "aws_cloudwatch_metric_alarm" "error_alarm_count_high" {
140+
# alarm_name = "search_patient_error_count_high"
141+
# alarm_description = "Triggers when search patient lambda error count is above 7 within 2mins"
142+
# comparison_operator = "GreaterThanThreshold"
143+
# evaluation_periods = 1
144+
# alarm_actions = [module.search_patient_alarm_topic.arn]
145+
# ok_actions = [module.search_patient_alarm_topic.arn]
146+
# threshold = 7
147+
# period = 120
148+
# dimensions = {
149+
# FunctionName = module.search-patient-details-lambda.function_name
150+
# }
151+
# metric_name = "Errors"
152+
# statistic = "Sum"
153+
# namespace = "AWS/Lambda"
154+
# tags = {
155+
# alerting_type = "KPI"
156+
# alarm_group = module.search-patient-details-lambda.function_name
157+
# }
158+
# }
159+
160+
125161

126162
module "search_patient_alarm_topic" {
127163
source = "./modules/sns"

0 commit comments

Comments
 (0)