[英]setting the widget for cloudwatch dashboard. Getting the error "The dashboard body is invalid, there are 1 validation errors"
[英]Cloudwatch Dashboard error in Cloudformation
我正在尝试使用 cloudformation 中的 JSON 在 AWS 系统管理器中创建 cloudwatch 仪表板。 我有一个模板,其中有几个 lambda 函数已经在堆栈中运行。 我将其更新如下:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "The AWS CloudFormation template for deployment. Version 1.0",
"Mappings": {
"SourceCode": {
"General": {
"S3Bucket": "solutions",
"KeyPrefix": "connected-solution/latest"
}
}
},
"Resources": {
"dashboard": {
"Type": "AWS::CloudWatch::Dashboard",
"Properties": {
"DashboardName": "Dynamodb-LambdaDashboard-xxx",
"DashboardBody": {
"widgets": [
{
"type": "metric",
"x": 0,
"y": 0,
"width": 12,
"height": 7,
"properties": {
"metrics": [
[
"AWS/DynamoDB",
"UserErrors"
]
],
"view": "timeSeries",
"stacked": false,
"period": 300,
"stat": "Sum",
"region": "us-east-1"
}
}
]
}
}
}
}
}
尝试更新堆栈时出现以下错误:
Property validation failure: [Value of property {/DashboardBody} does not match type {String}]
请指教。 有什么问题请告诉我,谢谢
DashboardBody
应该是string
,而不是 json object。 您必须对您的DashboardBody
进行字符串化(将 json object 转换为字符串)。 例如:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "The AWS CloudFormation template for deployment. Version 1.0",
"Mappings": {
"SourceCode": {
"General": {
"S3Bucket": "solutions",
"KeyPrefix": "connected-solution/latest"
}
}
},
"Resources": {
"dashboard": {
"Type": "AWS::CloudWatch::Dashboard",
"Properties": {
"DashboardName": "Dynamodb-LambdaDashboard-xxx",
"DashboardBody": "{\"widgets\":[{\"type\":\"metric\",\"x\":0,\"y\":0,\"width\":12,\"height\":7,\"properties\":{\"metrics\":[[\"AWS/DynamoDB\",\"UserErrors\"]],\"view\":\"timeSeries\",\"stacked\":false,\"period\":300,\"stat\":\"Sum\",\"region\":\"us-east-1\"}}]}"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.