Difference between revisions of "Aws cloudwatch metric alarm"

From wikieduonline
Jump to navigation Jump to search
Line 4: Line 4:
  
  
== ChatGPT example (01/2023) ==
+
== ChatGPT examples (01/2023) ==
 
  resource "aws_cloudwatch_metric_alarm" "elb_5xx_error_rate" {
 
  resource "aws_cloudwatch_metric_alarm" "elb_5xx_error_rate" {
 
   alarm_name                = "elb_5xx_error_rate"
 
   alarm_name                = "elb_5xx_error_rate"
Line 53: Line 53:
 
  }
 
  }
  
 +
resource "aws_cloudwatch_metric_alarm" "elb_response_time_90th_percentile" {
 +
  alarm_name                = "elb_response_time_90th_percentile"
 +
  comparison_operator      = "GreaterThanThreshold"
 +
  evaluation_periods        = "5"
 +
  metric_name              = "TargetResponseTime"
 +
  namespace                = "AWS/ApplicationELB"
 +
  period                    = "60"
 +
  statistic                = "p90"
 +
  threshold                = "1"
 +
  alarm_description        = "This alarm will notify when the 90th percentile of the response time is greater than 1 second for 5 consecutive data points"
 +
  alarm_actions            = [aws_sns_topic.example.arn]
 +
  dimensions = {
 +
    LoadBalancer = aws_elbv2_load_balancer.example.name
 +
  }
 +
}
  
  

Revision as of 09:50, 23 January 2023


ChatGPT examples (01/2023)

resource "aws_cloudwatch_metric_alarm" "elb_5xx_error_rate" {
 alarm_name                = "elb_5xx_error_rate"
 comparison_operator       = "GreaterThanThreshold"
 evaluation_periods        = "5"
 metric_name               = "HTTPCode_Backend_5XX"
 namespace                 = "AWS/ApplicationELB"
 period                    = "60"
 statistic                 = "SampleCount"
 threshold                 = "1"
 alarm_description         = "This alarm will notify when the 5XX error rate is greater than 1% for 5 consecutive minutes"
 alarm_actions             = [aws_sns_topic.example.arn]
 dimensions = {
   LoadBalancer = aws_elbv2_load_balancer.example.name
 }
}
resource "aws_cloudwatch_metric_alarm" "elb_response_time" {
 alarm_name                = "elb_response_time"
 comparison_operator       = "GreaterThanThreshold"
 evaluation_periods        = "5"
 metric_name               = "TargetResponseTime"
 namespace                 = "AWS/ApplicationELB"
 period                    = "60"
 statistic                 = "Average"
 threshold                 = "2"
 alarm_description         = "This alarm will notify when the average response time is greater than 2 seconds for 5 consecutive data points"
 alarm_actions             = [aws_sns_topic.example.arn]
 dimensions = {
   LoadBalancer = aws_elbv2_load_balancer.example.name
 }
}
resource "aws_cloudwatch_metric_alarm" "elb_response_time" {
 alarm_name                = "elb_response_time"
 comparison_operator       = "GreaterThanThreshold"
 evaluation_periods        = "5"
 metric_name               = "TargetResponseTime"
 namespace                 = "AWS/ApplicationELB"
 period                    = "60"
 statistic                 = "Maximum"
 threshold                 = "1"
 alarm_description         = "This alarm will notify when the maximum response time is greater than 1 second for 5 consecutive data points"
 alarm_actions             = [aws_sns_topic.example.arn]
 dimensions = {
   LoadBalancer = aws_elbv2_load_balancer.example.name
 }
}
resource "aws_cloudwatch_metric_alarm" "elb_response_time_90th_percentile" {
 alarm_name                = "elb_response_time_90th_percentile"
 comparison_operator       = "GreaterThanThreshold"
 evaluation_periods        = "5"
 metric_name               = "TargetResponseTime"
 namespace                 = "AWS/ApplicationELB"
 period                    = "60"
 statistic                 = "p90"
 threshold                 = "1"
 alarm_description         = "This alarm will notify when the 90th percentile of the response time is greater than 1 second for 5 consecutive data points"
 alarm_actions             = [aws_sns_topic.example.arn]
 dimensions = {
   LoadBalancer = aws_elbv2_load_balancer.example.name
 }
}



resource "aws_sns_topic" "example" {
 name = "example-topic"
}


See also

Advertising: