Skip to content

Commit

Permalink
fix: the alarm monitoring for 'unhealthyhost' wasn't working properly (
Browse files Browse the repository at this point in the history
…#614)

* use arn suffix for cloud alarm setup

* use Maximum instead of SampleCount
  • Loading branch information
wmoussa-gc authored Mar 11, 2024
1 parent 02613ee commit 4309971
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
8 changes: 4 additions & 4 deletions aws/alarms/cloudwatch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ resource "aws_cloudwatch_metric_alarm" "UnHealthyHostCount-TargetGroup1" {
metric_name = "UnHealthyHostCount"
namespace = "AWS/ApplicationELB"
period = "60" # Every minute
statistic = "SampleCount" # use the number of data points during the period
statistic = "Maximum" # the highest value observed during the specified period
treat_missing_data = "notBreaching" # don't alarm if there's no data
alarm_actions = [var.sns_topic_alert_critical_arn]
dimensions = {
LoadBalancer = var.lb_arn_suffix
TargetGroup = var.lb_target_group_1_arn
TargetGroup = var.lb_target_group_1_arn_suffix
}
}

Expand All @@ -85,12 +85,12 @@ resource "aws_cloudwatch_metric_alarm" "UnHealthyHostCount-TargetGroup2" {
metric_name = "UnHealthyHostCount"
namespace = "AWS/ApplicationELB"
period = "60" # Every minute
statistic = "SampleCount" # use the number of data points during the period
statistic = "Maximum" # the highest value observed during the specified period
treat_missing_data = "notBreaching" # don't alarm if there's no data
alarm_actions = [var.sns_topic_alert_critical_arn]
dimensions = {
LoadBalancer = var.lb_arn_suffix
TargetGroup = var.lb_target_group_2_arn
TargetGroup = var.lb_target_group_2_arn_suffix
}
}

Expand Down
8 changes: 4 additions & 4 deletions aws/alarms/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ variable "lb_arn_suffix" {
type = string
}

variable "lb_target_group_1_arn" {
description = "Load balancer target group 1 ARN"
variable "lb_target_group_1_arn_suffix" {
description = "Load balancer target group 1 ARN suffix, used by response time alarms"
type = string
}

variable "lb_target_group_2_arn" {
description = "Load balancer target group 2 ARN"
variable "lb_target_group_2_arn_suffix" {
description = "Load balancer target group 2 ARN suffix, used by response time alarms"
type = string
}

Expand Down
11 changes: 8 additions & 3 deletions aws/load_balancer/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ output "lb_target_group_1_arn" {
value = aws_lb_target_group.form_viewer_1.arn
}

output "lb_target_group_2_arn" {
description = "Load balancer target group 2 ARN"
value = aws_lb_target_group.form_viewer_2.arn
output "lb_target_group_1_arn_suffix" {
description = "Load balancer target group 1 ARN suffix for use with CloudWatch Alarm"
value = aws_lb_target_group.form_viewer_1.arn_suffix
}

output "lb_target_group_2_arn_suffix" {
description = "Load balancer target group 2 ARN suffix for use with CloudWatch Alarm"
value = aws_lb_target_group.form_viewer_2.arn_suffix
}

output "lb_target_group_1_name" {
Expand Down
12 changes: 6 additions & 6 deletions env/cloud/alarms/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ dependency "load_balancer" {
mock_outputs = {
lb_arn = null
lb_arn_suffix = null
lb_target_group_1_arn = null
lb_target_group_2_arn = null
lb_target_group_1_arn_suffix = null
lb_target_group_2_arn_suffix = null
}
}

Expand Down Expand Up @@ -108,10 +108,10 @@ inputs = {
kms_key_cloudwatch_arn = dependency.kms.outputs.kms_key_cloudwatch_arn
kms_key_cloudwatch_us_east_arn = dependency.kms.outputs.kms_key_cloudwatch_us_east_arn

lb_arn = dependency.load_balancer.outputs.lb_arn
lb_arn_suffix = dependency.load_balancer.outputs.lb_arn_suffix
lb_target_group_1_arn = dependency.load_balancer.outputs.lb_target_group_1_arn
lb_target_group_2_arn = dependency.load_balancer.outputs.lb_target_group_2_arn
lb_arn = dependency.load_balancer.outputs.lb_arn
lb_arn_suffix = dependency.load_balancer.outputs.lb_arn_suffix
lb_target_group_1_arn_suffix = dependency.load_balancer.outputs.lb_target_group_1_arn_suffix
lb_target_group_2_arn_suffix = dependency.load_balancer.outputs.lb_target_group_2_arn_suffix

sqs_reliability_deadletter_queue_arn = dependency.sqs.outputs.sqs_reliability_deadletter_queue_arn
sqs_audit_log_deadletter_queue_arn = dependency.sqs.outputs.sqs_audit_log_deadletter_queue_arn
Expand Down

0 comments on commit 4309971

Please sign in to comment.