2022-10-26 11:13:56 +08:00
|
|
|
resource "aws_cloudwatch_metric_alarm" "Kafka-ZooKeeperRequestLatencyMsMean" {
|
2023-05-23 13:10:16 +08:00
|
|
|
alarm_name = "${var.settings.ZooKeeperRequestLatencyMsMean.ecccode}-Kafka_${var.cluster-name}-ZooKeeperRequestLatencyMsMean"
|
2023-01-05 23:35:31 +08:00
|
|
|
comparison_operator = var.settings.ZooKeeperRequestLatencyMsMean.comparison_operator
|
|
|
|
evaluation_periods = var.settings.ZooKeeperRequestLatencyMsMean.evaluation_periods
|
2022-10-26 11:13:56 +08:00
|
|
|
metric_name = "ZooKeeperRequestLatencyMsMean"
|
2023-01-05 23:35:31 +08:00
|
|
|
period = var.settings.ZooKeeperRequestLatencyMsMean.period
|
|
|
|
statistic = var.settings.ZooKeeperRequestLatencyMsMean.statistic
|
|
|
|
threshold = var.settings.ZooKeeperRequestLatencyMsMean.threshold
|
2022-10-26 11:13:56 +08:00
|
|
|
alarm_description = "Kafka:ZooKeeperRequestLatencyMsMean"
|
|
|
|
namespace = "AWS/Kafka"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.ZooKeeperRequestLatencyMsMean.action]
|
|
|
|
ok_actions = [var.settings.ZooKeeperRequestLatencyMsMean.action]
|
2022-10-26 11:13:56 +08:00
|
|
|
dimensions = {
|
|
|
|
"Cluster Name" = var.cluster-name
|
|
|
|
}
|
|
|
|
}
|
2022-12-19 16:13:45 +08:00
|
|
|
|
|
|
|
data "aws_msk_cluster" "msk-cluster" {
|
|
|
|
cluster_name = var.cluster-name
|
|
|
|
}
|
|
|
|
|
|
|
|
data "aws_msk_broker_nodes" "msk-broker" {
|
|
|
|
cluster_arn = data.aws_msk_cluster.msk-cluster.arn
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "Kafka-CpuUserSystem" {
|
|
|
|
for_each = toset([for i in data.aws_msk_broker_nodes.msk-broker.node_info_list[*].broker_id : tostring(i)])
|
2023-05-23 13:10:16 +08:00
|
|
|
alarm_name = "${var.settings.CpuUserSystem.ecccode}-Kafka_${var.cluster-name}-${each.value}-CpuUsage"
|
2023-01-05 23:35:31 +08:00
|
|
|
comparison_operator = var.settings.CpuUserSystem.comparison_operator
|
|
|
|
evaluation_periods = var.settings.CpuUserSystem.evaluation_periods
|
|
|
|
threshold = var.settings.CpuUserSystem.threshold
|
2022-12-19 16:13:45 +08:00
|
|
|
alarm_description = "Kafka:ZooKeeperRequestLatencyMsMean"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.CpuUserSystem.action]
|
|
|
|
ok_actions = [var.settings.CpuUserSystem.action]
|
2022-12-19 16:13:45 +08:00
|
|
|
metric_query {
|
|
|
|
id = "m1"
|
|
|
|
metric {
|
|
|
|
metric_name = "CpuUser"
|
|
|
|
namespace = "AWS/Kafka"
|
2023-01-05 23:35:31 +08:00
|
|
|
period = var.settings.CpuUserSystem.period
|
|
|
|
stat = var.settings.CpuUserSystem.statistic
|
2022-12-19 16:13:45 +08:00
|
|
|
dimensions = {
|
|
|
|
"Cluster Name" = var.cluster-name
|
|
|
|
"Broker ID" = each.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
metric_query {
|
|
|
|
id = "m2"
|
|
|
|
metric {
|
|
|
|
metric_name = "CpuSystem"
|
|
|
|
namespace = "AWS/Kafka"
|
2023-01-05 23:35:31 +08:00
|
|
|
period = var.settings.CpuUserSystem.period
|
|
|
|
stat = var.settings.CpuUserSystem.statistic
|
2022-12-19 16:13:45 +08:00
|
|
|
dimensions = {
|
|
|
|
"Cluster Name" = var.cluster-name
|
|
|
|
"Broker ID" = each.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
metric_query {
|
|
|
|
id = "e1"
|
|
|
|
expression = "m1 + m2"
|
|
|
|
label = "CpuUserSystem"
|
|
|
|
return_data = "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "Kafka-KafkaDataLogsDiskUsed" {
|
|
|
|
for_each = toset([for i in data.aws_msk_broker_nodes.msk-broker.node_info_list[*].broker_id : tostring(i)])
|
2023-05-23 13:10:16 +08:00
|
|
|
alarm_name = "${var.settings.KafkaDataLogsDiskUsed.ecccode}-Kafka_${var.cluster-name}-${each.value}-KafkaDataLogsDiskUsed"
|
2023-01-05 23:35:31 +08:00
|
|
|
comparison_operator = var.settings.KafkaDataLogsDiskUsed.comparison_operator
|
|
|
|
evaluation_periods = var.settings.KafkaDataLogsDiskUsed.evaluation_periods
|
2022-12-19 16:13:45 +08:00
|
|
|
metric_name = "KafkaDataLogsDiskUsed"
|
2023-01-05 23:35:31 +08:00
|
|
|
period = var.settings.KafkaDataLogsDiskUsed.period
|
|
|
|
statistic = var.settings.KafkaDataLogsDiskUsed.statistic
|
|
|
|
threshold = var.settings.KafkaDataLogsDiskUsed.threshold
|
2022-12-19 16:13:45 +08:00
|
|
|
alarm_description = "Kafka:KafkaDataLogsDiskUsed"
|
|
|
|
namespace = "AWS/Kafka"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.KafkaDataLogsDiskUsed.action]
|
|
|
|
ok_actions = [var.settings.KafkaDataLogsDiskUsed.action]
|
2022-12-19 16:13:45 +08:00
|
|
|
dimensions = {
|
|
|
|
"Cluster Name" = var.cluster-name
|
|
|
|
"Broker ID" = each.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_cloudwatch_metric_alarm" "Kafka-HeapMemoryAfterGC" {
|
|
|
|
for_each = toset([for i in data.aws_msk_broker_nodes.msk-broker.node_info_list[*].broker_id : tostring(i)])
|
2023-05-23 13:10:16 +08:00
|
|
|
alarm_name = "${var.settings.HeapMemoryAfterGC.ecccode}-Kafka_${var.cluster-name}-${each.value}-HeapMemoryAfterGC"
|
2023-01-05 23:35:31 +08:00
|
|
|
comparison_operator = var.settings.HeapMemoryAfterGC.comparison_operator
|
|
|
|
evaluation_periods = var.settings.HeapMemoryAfterGC.evaluation_periods
|
2022-12-19 16:13:45 +08:00
|
|
|
metric_name = "HeapMemoryAfterGC"
|
2023-01-05 23:35:31 +08:00
|
|
|
period = var.settings.HeapMemoryAfterGC.period
|
|
|
|
statistic = var.settings.HeapMemoryAfterGC.statistic
|
|
|
|
threshold = var.settings.HeapMemoryAfterGC.threshold
|
2022-12-19 16:13:45 +08:00
|
|
|
alarm_description = "Kafka:HeapMemoryAfterGC"
|
|
|
|
namespace = "AWS/Kafka"
|
|
|
|
insufficient_data_actions = []
|
|
|
|
actions_enabled = var.actions-enabled
|
2023-01-05 23:35:31 +08:00
|
|
|
alarm_actions = [var.settings.HeapMemoryAfterGC.action]
|
|
|
|
ok_actions = [var.settings.HeapMemoryAfterGC.action]
|
2022-12-19 16:13:45 +08:00
|
|
|
dimensions = {
|
|
|
|
"Cluster Name" = var.cluster-name
|
|
|
|
"Broker ID" = each.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|