Skip to content

Commit 65c5449

Browse files
[PRM-134-v2] add alarm examples and subscription into separate file
1 parent 4e70b9e commit 65c5449

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# resource "aws_cloudwatch_metric_alarm" "search_patient_error_count_low" {
2+
# alarm_name = "search_patient_error_count_low"
3+
# alarm_description = "Triggers when search patient lambda error count is between 1 and 3 within 2mins"
4+
# comparison_operator = "GreaterThanThreshold"
5+
# threshold = 0
6+
# evaluation_periods = 1
7+
# alarm_actions = [module.search_patient_alarm_topic.arn]
8+
# ok_actions = [module.search_patient_alarm_topic.arn]
9+
# tags = {
10+
# is_kpi = "true"
11+
# alarm_group = module.search-patient-details-lambda.function_name
12+
# alarm_metric = "Errors"
13+
# severity = "low"
14+
# }
15+
# metric_query {
16+
# id = "error"
17+
# label = "error count for search patient, low if between 1 and 3"
18+
# return_data = true
19+
# expression = "IF(m1 >= 1 AND m1 <= 3, 1, 0)"
20+
# }
21+
#
22+
# metric_query {
23+
# id = "m1"
24+
#
25+
# metric {
26+
# metric_name = "Errors"
27+
# namespace = "AWS/Lambda"
28+
# period = 120
29+
# stat = "Sum"
30+
# dimensions = {
31+
# FunctionName = module.search-patient-details-lambda.function_name
32+
# }
33+
# }
34+
# }
35+
# }
36+
#
37+
# resource "aws_cloudwatch_metric_alarm" "search_patient_error_count_medium" {
38+
# alarm_name = "search_patient_error_count_medium"
39+
# alarm_description = "Triggers when search patient lambda error count is between 4 and 6 within 2mins"
40+
# comparison_operator = "GreaterThanThreshold"
41+
# threshold = 0
42+
# evaluation_periods = 1
43+
# alarm_actions = [module.search_patient_alarm_topic.arn]
44+
# ok_actions = [module.search_patient_alarm_topic.arn]
45+
# tags = {
46+
# is_kpi = "true"
47+
# alarm_group = module.search-patient-details-lambda.function_name
48+
# alarm_metric = "Errors"
49+
# severity = "medium"
50+
# }
51+
# metric_query {
52+
# id = "error"
53+
# label = "error count for search patient, medium if between 4 and 6"
54+
# return_data = true
55+
# expression = "IF(m1 >= 4 AND m1 <= 6, 1, 0)"
56+
# }
57+
#
58+
# metric_query {
59+
# id = "m1"
60+
#
61+
# metric {
62+
# metric_name = "Errors"
63+
# namespace = "AWS/Lambda"
64+
# period = 120
65+
# stat = "Sum"
66+
# dimensions = {
67+
# FunctionName = module.search-patient-details-lambda.function_name
68+
# }
69+
# }
70+
# }
71+
# }
72+
#
73+
# resource "aws_cloudwatch_metric_alarm" "search_patient_error_count_high" {
74+
# alarm_name = "search_patient_error_count_high"
75+
# alarm_description = "Triggers when search patient lambda error count is 7 or above"
76+
# comparison_operator = "GreaterThanThreshold"
77+
# threshold = 0
78+
# evaluation_periods = 1
79+
# alarm_actions = [module.search_patient_alarm_topic.arn]
80+
# ok_actions = [module.search_patient_alarm_topic.arn]
81+
# tags = {
82+
# is_kpi = "true"
83+
# alarm_group = module.search-patient-details-lambda.function_name
84+
# alarm_metric = "Errors"
85+
# severity = "high"
86+
# }
87+
# metric_query {
88+
# id = "error"
89+
# label = "error count for search patient, high if 7 or above"
90+
# return_data = true
91+
# expression = "IF(m1 >= 7, 1, 0)"
92+
# }
93+
#
94+
# metric_query {
95+
# id = "m1"
96+
#
97+
# metric {
98+
# metric_name = "Errors"
99+
# namespace = "AWS/Lambda"
100+
# period = 120
101+
# stat = "Sum"
102+
# dimensions = {
103+
# FunctionName = module.search-patient-details-lambda.function_name
104+
# }
105+
# }
106+
# }
107+
# }
108+
109+
# resource "aws_sns_topic_subscription" "im_alerting_search_patient" {
110+
# endpoint = module.im-alerting-lambda.lambda_arn
111+
# protocol = "lambda"
112+
# topic_arn = module.search_patient_alarm_topic.arn
113+
# }
114+
#
115+
# resource "aws_lambda_permission" "im_alerting_invoke_with_search_patient_sns" {
116+
# statement_id = "AllowExecutionFromSeachPatientAlarmSNS"
117+
# action = "lambda:InvokeFunction"
118+
# function_name = module.im-alerting-lambda.lambda_arn
119+
# principal = "sns.amazonaws.com"
120+
# source_arn = module.search_patient_alarm_topic.arn
121+
# }

0 commit comments

Comments
 (0)