data "aws_caller_identity" "this" {} resource "aws_cloudwatch_metric_alarm" "ES-CPUUtilization" { alarm_name = "${var.cw-alarm-prefix}:ES:CPUUtilization:${var.domain-name}" comparison_operator = "GreaterThanThreshold" evaluation_periods = "3" metric_name = "CPUUtilization" period = "1800" statistic = "Average" threshold = var.threshold-CPUUtilization alarm_description = "ES:CPUUtilization" namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled alarm_actions = [var.alarm-actions-urgent] ok_actions = [var.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id } tags = var.default-tags lifecycle { ignore_changes = [tags] } } resource "aws_cloudwatch_metric_alarm" "ES-SearchLatency" { alarm_name = "${var.cw-alarm-prefix}:ES:SearchLatency:${var.domain-name}" comparison_operator = "GreaterThanThreshold" evaluation_periods = "3" metric_name = "SearchLatency" period = "1800" statistic = "Average" threshold = var.threshold-SearchLatency alarm_description = "ES:SearchLatency" namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled alarm_actions = [var.alarm-actions-urgent] ok_actions = [var.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id } tags = var.default-tags lifecycle { ignore_changes = [tags] } } resource "aws_cloudwatch_metric_alarm" "ES-IndexingLatency" { alarm_name = "${var.cw-alarm-prefix}:ES:IndexingLatency:${var.domain-name}" comparison_operator = "GreaterThanThreshold" evaluation_periods = "3" metric_name = "IndexingLatency" period = "1800" statistic = "Average" threshold = var.threshold-IndexingLatency alarm_description = "ES:IndexingLatency" namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled alarm_actions = [var.alarm-actions-urgent] ok_actions = [var.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id } tags = var.default-tags lifecycle { ignore_changes = [tags] } } resource "aws_cloudwatch_metric_alarm" "ES-ClusterStatusRed" { alarm_name = "${var.cw-alarm-prefix}:ES:ClusterStatusRed:${var.domain-name}" comparison_operator = "GreaterThanThreshold" evaluation_periods = "2" metric_name = "ClusterStatus.red" period = "900" statistic = "Maximum" threshold = 0 alarm_description = "At least one primary shard and its replicas aren't allocated to a node." namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled alarm_actions = [var.alarm-actions-urgent] ok_actions = [var.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id } tags = var.default-tags lifecycle { ignore_changes = [tags] } }