gpt4 book ai didi

amazon-web-services - CloudWatch 警报 错误百分比 API 网关

转载 作者:行者123 更新时间:2023-12-03 23:46:01 25 4
gpt4 key购买 nike

我正在尝试使用 terraform 在 Cloudwatch 中设置和警报。我的报警基本上需要检查网关在1分钟的2个周期内是否有超过5%的5xx错误。

我尝试了以下代码,但它不起作用:

resource "aws_cloudwatch_metric_alarm" "gateway_error_rate" {
alarm_name = "gateway-errors"
comparison_operator = "GreaterThanOrEqualToThreshold"
alarm_description = "Gateway error rate has exceeded 5%"
treat_missing_data = "notBreaching"
metric_name = "5XXError"
namespace = "AWS/ApiGateway"
period = 60
evaluation_periods = 2
threshold = 5
statistic = "Average"
unit = "Percent"

dimensions = {
ApiName = "my-api"
Stage = "dev"
}
}

即使部署了警报,数据也不会显示。进行一些测试后,我注意到该警报显然不接受单位“百分比”。

有人有 terraformcloudformation 中有关如何配置此类警报的示例吗?

最佳答案

基于Marcin评论中提供的信息,我找到了this AWS 文档中的信息:

The Average statistic represents the 5XXError error rate, namely, the total count of the 5XXError errors divided by the total number of requests during the period. The denominator corresponds to the Count metric (below).

我在 terraform 中配置的警报如下所示:

resource "aws_cloudwatch_metric_alarm" "gateway_error_rate" {
alarm_name = "gateway-errors"
comparison_operator = "GreaterThanOrEqualToThreshold"
alarm_description = "Gateway error rate has exceeded 5%"
treat_missing_data = "notBreaching"
metric_name = "5XXError"
namespace = "AWS/ApiGateway"
period = 60
evaluation_periods = 2
threshold = 0.05
statistic = "Average"
unit = "Count"

dimensions = {
ApiName = "my-api"
Stage = "dev"
}
}

关于amazon-web-services - CloudWatch 警报 错误百分比 API 网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62709023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com