-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalarms.tf
More file actions
71 lines (60 loc) · 2.5 KB
/
alarms.tf
File metadata and controls
71 lines (60 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
resource "aws_cloudwatch_metric_alarm" "unhealthy_hosts" {
count = local.enable_alarms ? 1 : 0
alarm_name = "${local.resource_name}/unhealthy-hosts"
alarm_description = "Healthy host count dropped below ${var.alert_thresholds.min_healthy_host_count} on ${local.resource_name}"
comparison_operator = "LessThanThreshold"
evaluation_periods = 3
metric_name = "HealthyHostCount"
namespace = "AWS/ApplicationELB"
period = 60
statistic = "Average"
threshold = var.alert_thresholds.min_healthy_host_count
treat_missing_data = "breaching"
tags = local.tags
dimensions = {
LoadBalancer = aws_lb.this.arn_suffix
TargetGroup = aws_lb_target_group.this.arn_suffix
}
alarm_actions = [local.notification_arn]
ok_actions = [local.notification_arn]
}
resource "aws_cloudwatch_metric_alarm" "response_time" {
count = local.enable_alarms ? 1 : 0
alarm_name = "${local.resource_name}/response-time"
alarm_description = "Average response time >= ${var.alert_thresholds.response_time}s on ${local.resource_name}"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 3
metric_name = "TargetResponseTime"
namespace = "AWS/ApplicationELB"
period = 300
statistic = "Average"
threshold = var.alert_thresholds.response_time
treat_missing_data = "notBreaching"
tags = local.tags
dimensions = {
LoadBalancer = aws_lb.this.arn_suffix
TargetGroup = aws_lb_target_group.this.arn_suffix
}
alarm_actions = [local.notification_arn]
ok_actions = [local.notification_arn]
}
resource "aws_cloudwatch_metric_alarm" "error_5xx" {
count = local.enable_alarms ? 1 : 0
alarm_name = "${local.resource_name}/5xx-errors"
alarm_description = "5xx error count >= ${var.alert_thresholds.error_5xx_count} on ${local.resource_name}"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 1
metric_name = "HTTPCode_Target_5XX_Count"
namespace = "AWS/ApplicationELB"
period = 300
statistic = "Sum"
threshold = var.alert_thresholds.error_5xx_count
treat_missing_data = "notBreaching"
tags = local.tags
dimensions = {
LoadBalancer = aws_lb.this.arn_suffix
TargetGroup = aws_lb_target_group.this.arn_suffix
}
alarm_actions = [local.notification_arn]
ok_actions = [local.notification_arn]
}