Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AWS Cloudwatch Dashboard
#4
(20-02-2019, 06:16 AM)subham Wrote: Thanks ..It was a great help.

You're welcome.

Here is the upgraded version of the template that allows you to use variables input by user into the template using "Ref" with "Fn::Join"

Code:
JSON

{
   "AWSTemplateFormatVersion": "2010-09-09",
   "Description": "AWS CloudFormation Template Auto Dashboard Creation",
   "Metadata" : {"Created By": "Faizal Khan @ Ecomm India Cloud IT"},
   "Parameters": {
       "Server1CPU": {
           "Description": "What is the instance id of Server 1 for CPU Utilization?",
           "Type": "String"
       },
       "Server2CPU": {
           "Description": "What is the instance id of Server 2 for CPU Utilization?",
           "Type": "String"
       },
       "EBS1Disk": {
           "Description": "What is the volume id of Disk 1 for Volume Read Ops?",
           "Type": "String"
       },
       "EBS2Disk": {
           "Description": "What is the volume id of Disk 2 for Volume Read Ops?",
           "Type": "String"
       }
   },
   "Resources": {
       "AutomatedDashboard": {
           "Type": "AWS::CloudWatch::Dashboard",
           "Properties": {
               "DashboardName": "Dashboard-Multiple-EC2-EBS-Metrics",
               "DashboardBody": {
                   "Fn::Join": [
                       "",
                       [
                           "{\"widgets\":[{\"type\":\"metric\",\"x\":0,\"y\":0,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"AWS/EC2\",\"CPUUtilization\",\"InstanceId\",\"",
                           {
                               "Ref": "Server1CPU"
                           },
                           "\"],[\".\",\".\",\".\",\"",
                           {
                               "Ref": "Server2CPU"
                           },
                           "\"]],\"period\":300,\"stat\":\"Average\",\"region\":\"us-east-1\",\"title\":\"EC2 Instances CPU Utilization\"}},{\"type\":\"metric\",\"x\":12,\"y\":0,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"AWS/EBS\",\"VolumeReadOps\",\"VolumeId\",\"",
                           {
                               "Ref": "EBS1Disk"
                           },
                           "\"],[\".\",\".\",\".\",\"",
                           {
                               "Ref": "EBS2Disk"
                           },
                           "\"]],\"period\":300,\"stat\":\"Average\",\"region\":\"us-east-1\",\"title\":\"EBS Volumes ReadOps\"}}]}"
                       ]
                   ]
               }
           }
       }
   }
}





YAML

AWSTemplateFormatVersion: 2010-09-09
Description: AWS CloudFormation Template Auto Dashboard Creation
Metadata:
  Created By: Faizal Khan @ Ecomm India Cloud IT
Parameters:
  Server1CPU:
    Description: What is the instance id of Server 1 for CPU Utilization?
    Type: String
  Server2CPU:
    Description: What is the instance id of Server 2 for CPU Utilization?
    Type: String
  EBS1Disk:
    Description: What is the volume id of Disk 1 for Volume Read Ops?
    Type: String
  EBS2Disk:
    Description: What is the volume id of Disk 2 for Volume Read Ops?
    Type: String
Resources:
  AutomatedDashboard:
    Type: 'AWS::CloudWatch::Dashboard'
    Properties:
      DashboardName: Dashboard-Multiple-EC2-EBS-Metrics
      DashboardBody: !Join
        - ''
        - - >-
            {"widgets":[{"type":"metric","x":0,"y":0,"width":12,"height":6,"properties":{"metrics":[["AWS/EC2","CPUUtilization","InstanceId","
          - !Ref Server1CPU
          - '"],[".",".",".","'
          - !Ref Server2CPU
          - >-
            "]],"period":300,"stat":"Average","region":"us-east-1","title":"EC2
            Instances CPU
            Utilization"}},{"type":"metric","x":12,"y":0,"width":12,"height":6,"properties":{"metrics":[["AWS/EBS","VolumeReadOps","VolumeId","
          - !Ref EBS1Disk
          - '"],[".",".",".","'
          - !Ref EBS2Disk
          - >-
            "]],"period":300,"stat":"Average","region":"us-east-1","title":"EBS
            Volumes ReadOps"}}]}
Reply


Messages In This Thread
AWS Cloudwatch Dashboard - by subham - 19-02-2019, 12:46 PM
RE: AWS Cloudwatch Dashboard - by fzs - 19-02-2019, 01:40 PM
RE: AWS Cloudwatch Dashboard - by subham - 20-02-2019, 06:16 AM
RE: AWS Cloudwatch Dashboard - by fzs - 20-02-2019, 02:03 PM
RE: AWS Cloudwatch Dashboard - by subham - 21-02-2019, 11:23 AM
RE: AWS Cloudwatch Dashboard - by ananyagupta - 18-09-2019, 06:45 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)