File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -181,8 +181,8 @@ def waf_match_path(path_regex: str) -> JSON:
181181def add_waf_blocked_alarm (resources : JSON ) -> JSON :
182182 """
183183 Add a metric alarm that trips if the ratio between blocked and overall
184- requests goes above 25% . Note that requests blocked by rules listed in
185- :py:attr:`Config.waf_rules_not_logged` are not considered.
184+ requests goes above the set threshold . Note that requests blocked by rules
185+ listed in :py:attr:`Config.waf_rules_not_logged` are not considered.
186186 """
187187 if not config .enable_monitoring :
188188 return resources
@@ -208,6 +208,7 @@ def add_waf_blocked_alarm(resources: JSON) -> JSON:
208208 ]
209209 m_sum = '+' .join (f'm{ i } ' for i in range (1 , len (metrics )))
210210 expression = f'({ m_sum } )/(m0+{ m_sum } )*100'
211+ threshold = 25 if config .deployment_stage == 'prod' else 50
211212
212213 assert 'aws_cloudwatch_metric_alarm' not in resources
213214 return resources | {
@@ -240,7 +241,7 @@ def add_waf_blocked_alarm(resources: JSON) -> JSON:
240241 }
241242 ],
242243 'comparison_operator' : 'GreaterThanThreshold' ,
243- 'threshold' : 25 , # percent blocked of total requests in a period
244+ 'threshold' : threshold ,
244245 'evaluation_periods' : 1 ,
245246 'datapoints_to_alarm' : 1 ,
246247 'alarm_actions' : ['${data.aws_sns_topic.monitoring.arn}' ],
You can’t perform that action at this time.
0 commit comments