terraform - 获取 AWS CloudWatch 警报的 terraform 参考
问题描述
以下 terraform 资源创建 AWS cloudwatch 警报,但仍处于“数据不足”状态。我相信这是由于我使用的一些维度名称(DevicePath、fstype)可能不正确。我知道名称 MountPath 和 InstanceID 是正确的,但无法验证其他两个(DevicePath、fstype)。AWS 将这些维度分别称为路径、设备、fstype 和主机,但是,找不到 terraform 所称的参考。
resource "aws_cloudwatch_metric_alarm" "Low_Disk_Space_For_root_drive" {
alarm_name = "Low_Disk_Space_For_root_drive"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
metric_name = "disk_used_percent"
namespace = "CWAgent"
dimensions {
MountPath = "/"
DevicePath = "/dev/xvda2"
fstype = "xfs"
InstanceId = "i-xxxxxxxxxxxxxxxxx"
}
period = "60"
statistics = "Maximum"
threshold = "90"
alarm_description = "Disk usage for / is high"
insufficient_data_actions = []
actions_enabled = true
alarm_actions = ["arn:aws:sns:xxxxxx"]
ok_actions = ["arn:aws:sns:xxxxxx"]
}
解决方案
将 TreatMissingData 添加到资源主体
resource "aws_cloudwatch_metric_alarm" "Low_Disk_Space_For_root_drive"{
alarm_name = "Low_Disk_Space_For_root_drive"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
metric_name = "disk_used_percent"
namespace = "CWAgent"
dimensions {
MountPath = "/"
DevicePath = "/dev/xvda2"
fstype = "xfs"
InstanceId = "i-xxxxxxxxxxxxxxxxx"
}
period = "60"
statistics = "Maximum"
threshold = "90"
alarm_description = "Disk usage for / is high"
insufficient_data_actions = []
**TreatMissingData = "notBreaching"**
actions_enabled = true
alarm_actions = ["arn:aws:sns:xxxxxx"]
ok_actions = ["arn:aws:sns:xxxxxx"]
}
推荐阅读
- android - 日期的剩余天数未正确显示
- python - 我用 Python 编写的简单计算器中的流程顺序
- php - Base 64 编码图像
- reactjs - 跳转标记,跳转到反应原生地图中的下一个或最近的标记
- javascript - 无法使用角度项目中的模块名称从 node_modules 导入 .less 文件
- php - PHP Laravel - 无法与主机 mailtrap.io 建立连接 [连接超时 #10]
- uwp - 如何在 UWP 中创建弹出窗口
- java - 线程安全在两个数组列表之间移动数组列表元素
- mysql - 如何使用 SQL LIKE 匹配结果
- excel - VBA 从一个工作簿中复制数据以在另一个工作簿中引用