2022-12-30 00:01:39 +08:00
|
|
|
// The following checks requires container insights
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "eks-pod_cpu_utilization" {
|
|
|
|
for_each = toset(var.pod-names)
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_name = "${var.cw-alarm-prefix}:EKS:${var.cluster-name}:${each.value}:${var.settings.alarm1.metric}"
|
|
|
|
comparison_operator = var.settings.alarm1.comparison_operator
|
|
|
|
evaluation_periods = var.settings.alarm1.evaluation_periods
|
|
|
|
metric_name = var.settings.alarm1.metric
|
|
|
|
period = var.settings.alarm1.period
|
|
|
|
statistic = var.settings.alarm1.statistic
|
|
|
|
threshold = var.settings.alarm1.threshold
|
|
|
|
alarm_description = "EKS:${var.settings.alarm1.metric}"
|
2022-12-30 00:01:39 +08:00
|
|
|
namespace = "ContainerInsights"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.alarm1.action]
|
|
|
|
ok_actions = [var.settings.alarm1.action]
|
2022-12-30 00:01:39 +08:00
|
|
|
dimensions = {
|
|
|
|
"PodName" = each.value
|
|
|
|
"ClusterName" = var.cluster-name
|
|
|
|
"Namespace" = var.eks-namespace
|
|
|
|
}
|
|
|
|
tags = var.default-tags
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [tags]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "eks-pod_memory_utilization" {
|
|
|
|
for_each = toset(var.pod-names)
|
|
|
|
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_name = "${var.cw-alarm-prefix}:EKS:${var.cluster-name}:${each.value}:${var.settings.alarm2.metric}"
|
2022-12-30 00:01:39 +08:00
|
|
|
comparison_operator = "GreaterThanThreshold"
|
|
|
|
evaluation_periods = "3"
|
2023-01-05 23:35:31 +08:00
|
|
|
metric_name = var.settings.alarm2.metric
|
|
|
|
period = var.settings.alarm2.period
|
|
|
|
statistic = var.settings.alarm2.statistic
|
|
|
|
threshold = var.settings.alarm2.threshold
|
|
|
|
alarm_description = "EKS:${var.settings.alarm2.metric}"
|
2022-12-30 00:01:39 +08:00
|
|
|
namespace = "ContainerInsights"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.alarm2.action]
|
|
|
|
ok_actions = [var.settings.alarm2.action]
|
2022-12-30 00:01:39 +08:00
|
|
|
dimensions = {
|
|
|
|
"PodName" = each.value
|
|
|
|
"ClusterName" = var.cluster-name
|
|
|
|
"Namespace" = var.eks-namespace
|
|
|
|
}
|
|
|
|
tags = var.default-tags
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [tags]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "eks-pod_number_of_container_restarts" {
|
|
|
|
for_each = toset(var.pod-names)
|
|
|
|
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_name = "${var.cw-alarm-prefix}:EKS:${var.cluster-name}:${each.value}:${var.settings.alarm3.metric}"
|
2022-12-30 00:01:39 +08:00
|
|
|
comparison_operator = "GreaterThanThreshold"
|
|
|
|
evaluation_periods = "3"
|
2023-01-05 23:35:31 +08:00
|
|
|
metric_name = var.settings.alarm3.metric
|
|
|
|
period = var.settings.alarm3.period
|
|
|
|
statistic = var.settings.alarm3.statistic
|
|
|
|
threshold = var.settings.alarm3.threshold
|
|
|
|
alarm_description = "EKS:${var.settings.alarm3.metric}"
|
2022-12-30 00:01:39 +08:00
|
|
|
namespace = "ContainerInsights"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.alarm3.action]
|
|
|
|
ok_actions = [var.settings.alarm3.action]
|
2022-12-30 00:01:39 +08:00
|
|
|
dimensions = {
|
|
|
|
"PodName" = each.value
|
|
|
|
"ClusterName" = var.cluster-name
|
|
|
|
"Namespace" = var.eks-namespace
|
|
|
|
}
|
|
|
|
tags = var.default-tags
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [tags]
|
|
|
|
}
|
|
|
|
}
|