21-02-2019, 11:23 AM
Thanks for the above...Below is what i've tried something similar and get this working..Posting it here
Code:
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation Template Dashboard Creation
Resources:
CloudwatchDashboard:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: EC2-Sample-Dashboard
DashboardBody: { "Fn::Join": [ "", ['{
"widgets":[
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[ "AWS/EC2", "CPUUtilization", "InstanceId", "', { Ref: Ec2Instance1 }, '" ],
[ "AWS/EC2", "CPUUtilization", "InstanceId", "', { Ref: Ec2Instance2 }, '" ]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"EC2 Instances CPU Details"
}
},
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[ "AWS/EBS", "VolumeReadOps", "VolumeId", "vol-0e7060d9" ],
[ "AWS/EBS", "VolumeReadOps", "VolumeId", "vol-023c57f" ]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"EBS Details"
}
},
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[ "AWS/S3", "BucketSizeBytes", "BucketName", "bucket1" ],
[ "AWS/S3", "BucketSizeBytes", "BucketName", "bucket2" ]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"S3 Buckets Details"
}
},
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[ "AWS/EFS", "PermittedThroughput", "FileSystemId", "fs-f29a1" ],
[ "AWS/EFS", "PermittedThroughput", "FileSystemId", "fs-db382" ]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"EFS Details"
}
},
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[ "AWS/EC2", "DiskReadOps", "InstanceId", "', { Ref: Ec2Instance1 }, '" ],
[ "AWS/EC2", "DiskReadOps", "InstanceId", "', { Ref: Ec2Instance2 }, '" ]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"EC2 Disk Readops Details"
}
}
]
}'
] ] }
Ec2Instance1:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-04a5ff1d83d13aa06
InstanceType: t2.micro
AvailabilityZone: ap-southeast-1a
Ec2Instance2:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-04a5ff1d83d13aa06
InstanceType: t2.micro
AvailabilityZone: ap-southeast-1a