我正在创建一个EC2实例,同时在创建Terrawatch的Cloudwatch仪表板以提高CPU利用率。
我在
中使用了插值:$ {aws_instance.ec2-terminal-server.id}“指标”:[ [ “ AWS / EC2”, “ CPUUtilization”, “ Instanceid”, “ $ {aws_instance.ec2-terminal-server.id}” ]
resource "aws_cloudwatch_dashboard" "CWDashboardNotification" {
dashboard_name = "CPUUtilisation_${var.ec2_tags_name}"
dashboard_body = <<EOF
{
"widgets": [
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[
"AWS/EC2",
"CPUUtilization",
"Instanceid",
"${aws_instance.ec2-terminal-server.id}"
]
],
"period":300,
"stat":"Average",
"region":"ap-south-1",
"title":"EC2 Instance CPU"
}
}
]
}
EOF
}```
Output should show the cpu utilisation graph in the dashboard but it's showing blank