Skip to content

Instantly share code, notes, and snippets.

@loujaybee
Last active August 5, 2020 06:39
resource "aws_cloudwatch_metric_alarm" "error_rate" {
# ... rest of configuration
metric_query {
id = "errorCount"
metric {
metric_name = "Errors"
namespace = "AWS/Lambda"
period = 900
stat = "Sum"
dimensions = {
FunctionName = "${var.environment}-lambda"
}
}
}
metric_query {
id = "invocations"
metric {
metric_name = "Invocations"
namespace = "AWS/Lambda"
period = 900
stat = "Sum"
dimensions = {
FunctionName = "${var.environment}-lambda"
}
}
}
metric_query {
id = "errorRate"
expression = " ( errorCount / invocations ) * 100"
label = "Lambda error rate percentage"
return_data = "true"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment