Difference between revisions of "Aws cloudwatch metric alarm"
Jump to navigation
Jump to search
Line 28: | Line 28: | ||
namespace = "AWS/ApplicationELB" | namespace = "AWS/ApplicationELB" | ||
period = "60" | period = "60" | ||
− | statistic = "Average" | + | statistic = "[[Average]]" |
threshold = "2" | threshold = "2" | ||
alarm_description = "This alarm will notify when the average response time is greater than 2 seconds for 5 consecutive data points" | 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] | alarm_actions = [aws_sns_topic.example.arn] | ||
dimensions = { | dimensions = { |
Revision as of 09:46, 23 January 2023
ChatGPT example (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_sns_topic" "example" { name = "example-topic" }
See also
Advertising: