Editing Terraform resource: aws cloudwatch metric alarm

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm
 
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm
 
  aws_cloudwatch_metric_alarm
 
  aws_cloudwatch_metric_alarm
 
== Official example ==
 
resource "aws_cloudwatch_metric_alarm" "nlb_healthyhosts" {
 
  alarm_name          = "alarmname"
 
  comparison_operator = "[[LessThanThreshold]]"
 
  evaluation_periods  = "1"
 
  metric_name        = "HealthyHostCount"
 
  namespace          = "AWS/NetworkELB"
 
  period              = "60"
 
  statistic          = "Average"
 
  threshold          = var.logstash_servers_count
 
  alarm_description  = "Number of healthy nodes in Target Group"
 
  actions_enabled    = "true"
 
  alarm_actions      = [aws_sns_topic.sns.arn]
 
  ok_actions          = [aws_sns_topic.sns.arn]
 
  dimensions = {
 
    TargetGroup  = aws_lb_target_group.lb-tg.arn_suffix
 
    LoadBalancer = aws_lb.lb.arn_suffix
 
  }
 
}
 
  
 
== Examples ==
 
== Examples ==
Line 30: Line 10:
 
   evaluation_periods  = "2"
 
   evaluation_periods  = "2"
 
   [[metric_name]]        = "[[CPUUtilization]]"
 
   [[metric_name]]        = "[[CPUUtilization]]"
   [[namespace]]           = "[[AWS/NetworkELB]]"
+
   namespace          = "[[AWS/RDS]]"
 
   period              = "30"
 
   period              = "30"
   [[statistic]]          = "[[SampleCount]]"
+
   [[statistic]]          = "Average"
   threshold          = "0"
+
   threshold          = "80"
   alarm_description  = "No healthy target group available to LB listener"
+
   alarm_description  = "Average database CPU utilization is too high."
 
   
 
   
 
   dimensions = {
 
   dimensions = {
     HealthyHostCount = [[aws_lb]].your-load-balancer-name.id
+
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
   }
 
   }
 
  }
 
  }
  
== [[AWS/RDS]] ==
 
 
[[CPU]]
 
[[CPU]]
 
  resource "aws_cloudwatch_metric_alarm" "db_cpu_utilization_too_high" {
 
  resource "aws_cloudwatch_metric_alarm" "db_cpu_utilization_too_high" {
Line 59: Line 38:
 
  }
 
  }
  
[[DiskQueueDepth]]
+
<pre>
+
resource "aws_cloudwatch_metric_alarm" "db_disk_queue_depth_too_high" {
resource "aws_cloudwatch_metric_alarm" "db_disk_queue_depth_too_high" {
 
 
   alarm_name          = format("%s-%s", lower("${var.rds_name}"), "db-highDiskQueueDepth")
 
   alarm_name          = format("%s-%s", lower("${var.rds_name}"), "db-highDiskQueueDepth")
 
   comparison_operator = "GreaterThanThreshold"
 
   comparison_operator = "GreaterThanThreshold"
Line 71: Line 49:
 
   threshold          = "10"
 
   threshold          = "10"
 
   alarm_description  = "Average database disk queue depth is too high, performance may be negatively impacted."
 
   alarm_description  = "Average database disk queue depth is too high, performance may be negatively impacted."
+
 
 
   dimensions = {
 
   dimensions = {
 
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
   }
 
   }
}
+
}
 
 
[[FreeStorageSpace]]
 
  
resource "aws_cloudwatch_metric_alarm" "db_disk_free_storage_space_too_low" {
+
resource "aws_cloudwatch_metric_alarm" "db_disk_free_storage_space_too_low" {
 
   alarm_name          = format("%s-%s", lower("${var.rds_name}"), "db-lowFreeStorageSpace")
 
   alarm_name          = format("%s-%s", lower("${var.rds_name}"), "db-lowFreeStorageSpace")
 
   comparison_operator = "[[LessThanThreshold]]"
 
   comparison_operator = "[[LessThanThreshold]]"
Line 93: Line 69:
 
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
   }
 
   }
}
+
}
  
[[FreeableMemory]]
+
resource "aws_cloudwatch_metric_alarm" "db_memory_freeable_too_low" {
resource "aws_cloudwatch_metric_alarm" "db_memory_freeable_too_low" {
 
 
   alarm_name          = format("%s-%s", lower("${var.rds_name}"), "db-lowFreeableMemory")
 
   alarm_name          = format("%s-%s", lower("${var.rds_name}"), "db-lowFreeableMemory")
 
   comparison_operator = "LessThanThreshold"
 
   comparison_operator = "LessThanThreshold"
Line 110: Line 85:
 
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
     DBInstanceIdentifier = aws_db_instance.rds_instance.id
 
   }
 
   }
}
+
}
 +
</pre>
  
 
== ChatGPT examples for [[ALB]] (01/2023) ==
 
== ChatGPT examples for [[ALB]] (01/2023) ==
Line 118: Line 94:
 
   evaluation_periods        = "5"
 
   evaluation_periods        = "5"
 
   [[metric_name]]              = "[[HTTPCode_Backend_5XX]]"
 
   [[metric_name]]              = "[[HTTPCode_Backend_5XX]]"
   [[namespace]]                = "[[AWS/ApplicationELB]]"
+
   [[namespace]]                = "AWS/ApplicationELB"
 
   period                    = "60"
 
   period                    = "60"
 
   statistic                = "SampleCount"
 
   statistic                = "SampleCount"

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Templates used on this page:

Advertising: