-
Notifications
You must be signed in to change notification settings - Fork 2
CCM-14044 Setting prod defaults #439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b575efc
d9ff0a9
281824f
1c64bb8
9a4f5db
40c7e46
7125454
06aa14f
7222602
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| resource "aws_cloudwatch_metric_alarm" "subscriber_anomaly" { | ||
| count = var.enable_event_anomaly_detection ? 1 : 0 | ||
|
|
||
| alarm_name = "${local.csi}-subscriber-anomaly" | ||
| alarm_description = "ANOMALY: Detects anomalous patterns in messages published to the SNS fanout topic" | ||
| comparison_operator = "LessThanLowerOrGreaterThanUpperThreshold" | ||
| evaluation_periods = var.event_anomaly_evaluation_periods | ||
| threshold_metric_id = "ad1" | ||
| treat_missing_data = "notBreaching" | ||
|
|
||
| metric_query { | ||
| id = "m1" | ||
| return_data = true | ||
|
|
||
| metric { | ||
| metric_name = "NumberOfNotificationsDelivered" | ||
| namespace = "AWS/SNS" | ||
| period = var.event_anomaly_period | ||
| stat = "Sum" | ||
|
|
||
| dimensions = { | ||
| TopicName = aws_sns_topic.main.name | ||
| } | ||
| } | ||
| } | ||
|
|
||
| metric_query { | ||
| id = "ad1" | ||
| expression = "ANOMALY_DETECTION_BAND(m1, ${var.event_anomaly_band_width})" | ||
| label = "NumberOfNotificationsDelivered (expected)" | ||
| return_data = true | ||
| } | ||
|
|
||
| tags = merge( | ||
| var.default_tags, | ||
| { | ||
| Name = "${local.csi}-subscriber-anomaly" | ||
| } | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,39 @@ variable "sns_success_logging_sample_percent" { | |
| default = 0 | ||
| } | ||
|
|
||
| ## | ||
| # CloudWatch Anomaly Detection Variables | ||
| ## | ||
|
|
||
| variable "enable_event_anomaly_detection" { | ||
| type = bool | ||
| description = "Enable CloudWatch anomaly detection alarm for SNS topic message publishing" | ||
| default = true | ||
| } | ||
|
|
||
| variable "event_anomaly_evaluation_periods" { | ||
| type = number | ||
| description = "Number of evaluation periods for the anomaly alarm. Each period is defined by event_anomaly_period." | ||
| default = 2 | ||
| } | ||
|
|
||
| variable "event_anomaly_period" { | ||
| type = number | ||
| description = "The period in seconds over which the specified statistic is applied for anomaly detection. Minimum 300 seconds (5 minutes). Recommended: 300-600." | ||
| default = 300 | ||
| } | ||
|
|
||
| variable "event_anomaly_band_width" { | ||
| type = number | ||
| description = "The width of the anomaly detection band. Higher values (e.g. 4-6) reduce sensitivity and noise, lower values (e.g. 2-3) increase sensitivity. Recommended: 2-4." | ||
| default = 3 | ||
|
|
||
| validation { | ||
| condition = var.event_anomaly_band_width >= 2 && var.event_anomaly_band_width <= 10 | ||
| error_message = "Band width must be between 2 and 10" | ||
| } | ||
|
Comment on lines
+109
to
+112
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed here? Is the anomaly threshold particularly important here? Again, I think 5 is already big
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe not especially, but ive tried to keep this consistent across the bounded contexts. probably more of a thing for the publisher really. |
||
| } | ||
|
|
||
| variable "log_level" { | ||
| type = string | ||
| description = "The log level to be used in lambda functions within the component. Any log with a lower severity than the configured value will not be logged: https://docs.python.org/3/library/logging.html#levels" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About LessThanLower - do we want to alert on drops too? I think there'll be periods when not in use?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe the way the threshold should work would be fine. we do want alerts when we get messages just unespectedly vanish. Something being updated somewhere and events just stopping is the case im most worried with