From 597aa0736f3c0a62e4b26d34c7b7737e23f124f6 Mon Sep 17 00:00:00 2001 From: xpk Date: Mon, 21 Nov 2022 14:55:32 +0800 Subject: [PATCH] UPD: removed checks specified by customer, add checks from default CW agent config --- modules/ManagementGovernance/Monitoring.EC2/main.tf | 10 ++++++++-- .../ManagementGovernance/Monitoring.EC2/variables.tf | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/ManagementGovernance/Monitoring.EC2/main.tf b/modules/ManagementGovernance/Monitoring.EC2/main.tf index 43daec7..808b02d 100644 --- a/modules/ManagementGovernance/Monitoring.EC2/main.tf +++ b/modules/ManagementGovernance/Monitoring.EC2/main.tf @@ -83,6 +83,7 @@ data "external" "ec2-os" { # Linux specific checks # default cw agent uses mem_used_percent metric +/* resource "aws_cloudwatch_metric_alarm" "ec2-mem_free" { count = data.external.ec2-os.result.os == "Linux" ? 1 : 0 alarm_name = "${var.cw-alarm-prefix}:EC2:mem_free:${var.ec2-instance-id}" @@ -108,6 +109,7 @@ resource "aws_cloudwatch_metric_alarm" "ec2-mem_free" { ignore_changes = [tags] } } +*/ resource "aws_cloudwatch_metric_alarm" "ec2-mem_used_percent" { count = data.external.ec2-os.result.os == "Linux" ? 1 : 0 @@ -136,6 +138,7 @@ resource "aws_cloudwatch_metric_alarm" "ec2-mem_used_percent" { } # default cw agent uses swap_used_percent metric +/* resource "aws_cloudwatch_metric_alarm" "ec2-swap_free" { count = data.external.ec2-os.result.os == "Linux" ? 1 : 0 # zero is fine as most ec2 instances are deployed without any swap @@ -174,6 +177,7 @@ resource "aws_cloudwatch_metric_alarm" "ec2-swap_free" { ignore_changes = [tags] } } +*/ data "external" "cw-dimensions" { program = ["bash", "${path.module}/get-cwagent-dimensions.sh"] @@ -196,8 +200,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-swap_used_percent" { namespace = "CWAgent" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.sns-targets.alarm-actions-standard] - ok_actions = [var.sns-targets.alarm-actions-standard] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { InstanceId = var.ec2-instance-id ImageId = data.aws_instance.ec2-instance.ami @@ -210,6 +214,7 @@ resource "aws_cloudwatch_metric_alarm" "ec2-swap_used_percent" { } # default cw agent uses disk_used_percent metric +/* resource "aws_cloudwatch_metric_alarm" "ec2-disk_free" { count = data.external.ec2-os.result.os == "Linux" && length(data.external.cw-dimensions.result) > 0 ? 1 : 0 alarm_name = "${var.cw-alarm-prefix}:EC2:disk_free:${var.ec2-instance-id}" @@ -232,6 +237,7 @@ resource "aws_cloudwatch_metric_alarm" "ec2-disk_free" { ignore_changes = [tags] } } +*/ resource "aws_cloudwatch_metric_alarm" "ec2-disk_used_percent" { count = data.external.ec2-os.result.os == "Linux" && length(data.external.cw-dimensions.result) > 0 ? 1 : 0 diff --git a/modules/ManagementGovernance/Monitoring.EC2/variables.tf b/modules/ManagementGovernance/Monitoring.EC2/variables.tf index 84780c1..c8ddc97 100644 --- a/modules/ManagementGovernance/Monitoring.EC2/variables.tf +++ b/modules/ManagementGovernance/Monitoring.EC2/variables.tf @@ -6,11 +6,11 @@ variable sns-targets {} variable "default-tags" {} variable "threshold-CPUUtilization" {} -variable "threshold-mem_free" {} +# variable "threshold-mem_free" {} variable "threshold-mem_used_percent" {} -variable "threshold-swap_free" {} +# variable "threshold-swap_free" {} variable "threshold-swap_used_percent" {} -variable "threshold-disk_free" {} +# variable "threshold-disk_free" {} variable "threshold-disk_used_percentage" {} variable "threshold-disk_inodes_free" {} variable "threshold-processes_total" {}