[英]AWS CloudWatch dashboard CloudFormation configuration
I'm trying to confgure a dashboard with a basic widget to expose CpUUtilization metric. 我正在尝试使用基本小部件来配置仪表板以公开CpUUtilization指标。 I cannot reference the previous created EC2 instance, since it seems that in the json that describe the dashboard the !Ref function is not interpreted. 我无法引用之前创建的EC2实例,因为似乎在描述仪表板的json中没有解释!Ref函数。
metrics": [
"AWS/EC2",
"CPUUtilization",
"InstanceId",
"!Ref Ec2Instance"
]
Any idea how to reference it by logical name? 知道如何通过逻辑名称引用它吗?
You can use Fn::Join
to combine the output of Intrinsic functions (like Ref
) with strings. 您可以使用Fn::Join
将内部函数(如Ref
)的输出与字符串组合在一起。 For example: 例如:
CloudWatchDashboardHOSTNAME:
Type: "AWS::CloudWatch::Dashboard"
DependsOn: Ec2InstanceHOSTNAME
Properties:
DashboardName: HOSTNAME
DashboardBody: { "Fn::Join": [ "", ['{"widgets":[
{
"type":"metric",
"properties":{
"metrics":[
["AWS/EC2","CPUUtilization","InstanceId",
"', { Ref: Ec2InstanceHOSTNAME }, '"]
],
"title":"CPU Utilization",
"period":60,
"region":"us-east-1"
}
}]}' ] ] }
Documentation: 文档:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.