-
Notifications
You must be signed in to change notification settings - Fork 12
/
alerts.tf
58 lines (56 loc) · 2.42 KB
/
alerts.tf
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
resource "aws_cloudwatch_metric_alarm" "CPUUtilization_alarm" {
alarm_name = "${var.app}-cpu-${var.environment}"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = "AWS/ECS"
period = "120"
statistic = "Average"
threshold = var.cpu_alert_threshold
alarm_description = "This metric monitors ECS CPU utilization for ${var.app}"
alarm_actions = var.alert_actions
ok_actions = var.alert_actions
insufficient_data_actions = []
treat_missing_data = "notBreaching"
dimensions = {
ServiceName = "${aws_ecs_cluster.app.name}"
ClusterName = "${aws_ecs_service.app.name}"
}
}
resource "aws_cloudwatch_metric_alarm" "MemoryUtilization_alarm" {
alarm_name = "${var.app}-memory-${var.environment}"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
metric_name = "MemoryUtilization"
namespace = "AWS/ECS"
period = "120"
statistic = "Average"
threshold = var.memory_alert_threshold
alarm_description = "This metric monitors ECS memory utilization for ${var.app}"
alarm_actions = var.alert_actions
ok_actions = var.alert_actions
insufficient_data_actions = []
treat_missing_data = "notBreaching"
dimensions = {
ServiceName = "${aws_ecs_cluster.app.name}"
ClusterName = "${aws_ecs_service.app.name}"
}
}
resource "aws_cloudwatch_metric_alarm" "HTTPCode_ELB_5XX_Count_alarm" {
alarm_name = "${var.app}-http5xx-${var.environment}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "HTTPCode_Target_5XX_Count"
namespace = "AWS/ApplicationELB"
period = "300"
statistic = "Sum"
threshold = var.HTTPCode_ELB_5XX_threshold
alarm_description = "HTTP 5XX alarm for over 25 counts within 5 minutes for ${var.app}"
alarm_actions = var.alert_actions
ok_actions = var.alert_actions
insufficient_data_actions = []
treat_missing_data = "notBreaching"
dimensions = {
LoadBalancer = "${aws_alb.main[0].arn_suffix}"
}
}