-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathalarms.tf
81 lines (78 loc) · 2.31 KB
/
alarms.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
resource "aws_cloudwatch_metric_alarm" "elasticache_alarm_cpu" {
count = var.num_cache_nodes
alarm_name = "elasticache-alarm-cpu-${var.cluster_id}-00${count.index + 1}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 2
metric_name = "CPUUtilization"
namespace = "AWS/ElastiCache"
period = 60
threshold = var.alarm_threshold_cpu
statistic = "Average"
alarm_actions = [
var.alarm_sns_topic,
]
ok_actions = [
var.alarm_sns_topic,
]
dimensions = {
CacheClusterId = var.cluster_id
}
}
resource "aws_cloudwatch_metric_alarm" "elasticache_alarm_memory" {
count = var.num_cache_nodes
alarm_name = "elasticache-alarm-memory-${var.cluster_id}-00${count.index + 1}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 2
metric_name = "DatabaseMemoryUsagePercentage"
namespace = "AWS/ElastiCache"
period = 60
threshold = var.alarm_threshold_memory
statistic = "Average"
alarm_actions = [
var.alarm_sns_topic,
]
ok_actions = [
var.alarm_sns_topic,
]
dimensions = {
CacheClusterId = var.cluster_id
}
}
resource "aws_cloudwatch_metric_alarm" "elasticache_alarm_evictions" {
alarm_name = "elasticache-alarm-evictions-${var.cluster_id}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 2
metric_name = "Evictions"
namespace = "AWS/ElastiCache"
period = 960
threshold = var.alarm_threshold_evictions
statistic = "Average"
alarm_actions = [
var.alarm_sns_topic,
]
ok_actions = [
var.alarm_sns_topic,
]
dimensions = {
CacheClusterId = var.cluster_id
}
}
resource "aws_cloudwatch_metric_alarm" "elasticache_alarm_swap" {
alarm_name = "elasticache-alarm-swap-${var.cluster_id}"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 2
metric_name = "SwapUsage"
namespace = "AWS/ElastiCache"
period = 300
threshold = var.alarm_threshold_swap
statistic = "Average"
alarm_actions = [
var.alarm_sns_topic,
]
ok_actions = [
var.alarm_sns_topic,
]
dimensions = {
CacheClusterId = var.cluster_id
}
}