-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudwatch.tf
57 lines (51 loc) · 1.91 KB
/
cloudwatch.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
resource "aws_cloudwatch_log_group" "svc" {
name = "${var.name}-${var.env}"
}
resource "aws_cloudwatch_metric_alarm" "cpu" {
alarm_name = "${var.name}-${var.env}-high-cpu"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 2 # 10 Minutes
metric_name = "CpuUtilized"
namespace = "ECS/ContainerInsights"
period = "300" # 5 minutes
statistic = "Average"
threshold = "75"
actions_enabled = false
alarm_description = "Monitors ${var.name}-${var.env} for continued high CPU percentage"
dimensions = {
ServiceName = "${var.name}-${var.env}"
ClusterName = "${var.name}-${var.env}"
}
}
resource "aws_cloudwatch_metric_alarm" "memory" {
alarm_name = "${var.name}-${var.env}-high-memory"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 2 # 10 Minutes
metric_name = "MemoryUtilized"
namespace = "ECS/ContainerInsights"
period = "300" # 5 minutes
statistic = "Average"
threshold = "75"
actions_enabled = false
alarm_description = "Monitors ${var.name}-${var.env} for continued high Memory percentage"
dimensions = {
ServiceName = "${var.name}-${var.env}"
ClusterName = "${var.name}-${var.env}"
}
}
resource "aws_cloudwatch_metric_alarm" "running" {
alarm_name = "${var.name}-${var.env}-running-tasks"
comparison_operator = "LessThanOrEqualToThreshold"
evaluation_periods = 1 # 5 Minutes
metric_name = "RunningTaskCount"
namespace = "ECS/ContainerInsights"
period = "300" # 5 minutes
statistic = "Average"
threshold = "1"
actions_enabled = false
alarm_description = "Monitors ${var.name}-${var.env} for <=1 running task"
dimensions = {
ServiceName = "${var.name}-${var.env}"
ClusterName = "${var.name}-${var.env}"
}
}