Skip to content

Commit 8bda13f

Browse files
committed
Setup CloudWatch alarm for ClamAV notifications (#3895, PR #6024)
2 parents 252eaa1 + cde7d15 commit 8bda13f

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

terraform/cloudwatch.tf.json.template.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def prod_qualified_resource_name(name: str) -> str:
201201
{
202202
'id': 'log_count_raw',
203203
'metric': {
204-
'metric_name': config.qualified_resource_name(f'{lambda_}cachehealth'),
204+
'metric_name': '${aws_cloudwatch_log_metric_filter.'
205+
'%scachehealth.metric_transformation[0].name}' % lambda_,
205206
'namespace': 'LogMetrics',
206207
'period': 10 * 60,
207208
'stat': 'Sum',

terraform/shared/shared.tf.json.template.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ def paren(s: str) -> str:
551551
'alarm_name': config.qualified_resource_name(a.name, suffix='.alarm'),
552552
'comparison_operator': 'GreaterThanOrEqualToThreshold',
553553
'evaluation_periods': 1,
554-
'metric_name': a.metric_name,
554+
'metric_name': '${aws_cloudwatch_log_metric_filter.'
555+
'%s.metric_transformation[0].name}' % a.name,
555556
'namespace': 'LogMetrics',
556557
'statistic': a.statistic,
557558
'treat_missing_data': 'notBreaching',
@@ -565,22 +566,25 @@ def paren(s: str) -> str:
565566
for a in cis_alarms
566567
},
567568
**{
568-
'clam_fail': {
569-
'alarm_name': config.qualified_resource_name('clam_fail', suffix='.alarm'),
569+
resource_name: {
570+
'alarm_name': config.qualified_resource_name(resource_name, suffix='.alarm'),
570571
'comparison_operator': 'GreaterThanOrEqualToThreshold',
571572
'evaluation_periods': 1,
572-
'metric_name': 'clam_fail',
573+
'metric_name': '${aws_cloudwatch_log_metric_filter.'
574+
'%s.metric_transformation[0].name}' % resource_name,
573575
'namespace': 'LogMetrics',
574576
'statistic': 'Sum',
575577
'treat_missing_data': 'notBreaching',
576578
'threshold': 1,
579+
'period': period,
580+
'alarm_actions': ['${aws_sns_topic.monitoring.arn}'],
581+
'ok_actions': ['${aws_sns_topic.monitoring.arn}']
582+
} for resource_name, period in [
577583
# With ClamScan running twice a day we've got a 12h period,
578584
# plus 8h upper bound on running time, minus 2h lower bound
579585
# on running time, giving us an 18h evaluation period.
580-
'period': 18 * 60 * 60,
581-
'alarm_actions': ['${aws_sns_topic.monitoring.arn}'],
582-
'ok_actions': ['${aws_sns_topic.monitoring.arn}']
583-
}
586+
('clam_fail', 18 * 60 * 60)
587+
]
584588
},
585589
**{
586590
resource_name: {
@@ -607,7 +611,8 @@ def paren(s: str) -> str:
607611
{
608612
'id': 'log_count_raw',
609613
'metric': {
610-
'metric_name': config.qualified_resource_name(resource_name),
614+
'metric_name': '${aws_cloudwatch_log_metric_filter.'
615+
'%s.metric_transformation[0].name}' % resource_name,
611616
'namespace': 'LogMetrics',
612617
'period': period,
613618
'stat': 'Sum',

0 commit comments

Comments
 (0)