Skip to content

Instantly share code, notes, and snippets.

@simontabor
Created June 4, 2019 09:22
Show Gist options
  • Save simontabor/7581459b218caefc11d83870aac8a226 to your computer and use it in GitHub Desktop.
Save simontabor/7581459b218caefc11d83870aac8a226 to your computer and use it in GitHub Desktop.
resource "aws_cloudwatch_metric_alarm" "alb_error_rate" {
alarm_name = "${aws_lb.main.name}-alb-error-rate"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 2
threshold = 5
alarm_description = "Load balancer error rate has exceeded 5%"
treat_missing_data = "notBreaching"
metric_query {
id = "error_rate"
expression = "5xx_count / request_count *100"
label = "Error Rate"
return_data = true
}
# metric queries for 5xx_count and request_count...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment