19-02-2019, 01:40 PM
(19-02-2019, 12:46 PM)subham Wrote: I've a requirement where in i'm trying to create clouldwatch dashboard for my service,I've nearly 20 servers for which i wish to create dashboard with multiple widget.
I wish to write cloudformation script for the same in yaml format as i'm using yaml for other stuffs,i tried to refer docs but dint get much about my requirement
Hello Subham,
Below is a sample template you can use for this. This template creates 2 widgets inside a single dashbaord with each widget having 2 resources in it. One widget shows the CPU utilization of 2 instances and the other widget shows the Volume Read Ops of 2 EBS volumes. To add more resources, just replicate the metrics section as many times as you desire. You can of course add resource references to automatically pick up instance ids and volume ids if you wish to.
Code:
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation Template Auto Dashboard Creation
Resources:
DashboardSideBySide:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: EC2-EBS-Metrics
DashboardBody: '{
"widgets":[
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[
"AWS/EC2",
"CPUUtilization",
"InstanceId",
"i-xxxxxxxxxxxxx"
],
[
"AWS/EC2",
"CPUUtilization",
"InstanceId",
"i-xxxxxxxxxxxxx"
]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"EC2 Instances CPU"
}
},
{
"type":"metric",
"x":0,
"y":0,
"width":12,
"height":6,
"properties":{
"metrics":[
[
"AWS/EBS",
"VolumeReadOps",
"VolumeId",
"vol-xxxxxxxxxxxxx"
],
[
"AWS/EBS",
"VolumeReadOps",
"VolumeId",
"vol-xxxxxxxxxxxxx"
]
],
"period":300,
"stat":"Average",
"region":"us-east-1",
"title":"EBS Volume Read Ops"
}
}
]
}'