简体   繁体   中英

AWS powershell commandlet (Write-CWDashboard) outputs message 'Should match exactly one schema in oneOf'

I was trying to create AWS cloudwatch dashboard using AWS powershell commandlet Write-CWDashboard. Though the command was successful but it's generating an output message as 'Should match exactly one schema in oneOf'. Complete details are below,

I would like to understand why is it generating that message.

Command:

Write-CWDashboard -DashboardName 'test' -DashboardBody $DashboardBody;

$DashboardBody value in json format:

{ "widgets": [    
    {
        "type": "metric",
        "x": 0,
        "y": 0,
        "width": 10,
        "height": 10,
        "properties": {
            "region": "us-west-2",
            "metrics": [
["AWS/EC2", "CPUUtilization", "InstanceId", "i-04c3216xyz"]
            ],
            "view": "timeSeries",
            "stacked": false,
            "title": "server01 CPU",
            "legend": {
                "position": "right"
            }
        }
    },  
    {
        "type": "metric",
        "x": 0,
        "y": 10,
        "width": 10,
        "height": 10,
        "properties": {
            "region": "us-west-2",
            "metrics": [
["AWS/EBS", "VolumeReadOps", "VolumeId", "vol-0b1ab41abc"],
["AWS/EBS", "VolumeWriteOps", "VolumeId", "vol-0b1ab41abc"]
            ],
            "view": "timeSeries",
            "stacked": false,
            "annotations": {
            },
            "title": "server01 disk01 IOPs",
            "legend": {
                "position": "right"
            }
        }
    }
    ]}

Output:

DataPath                           Message
--------                           -------
/widgets/1/properties/annotations  Should match exactly one schema in oneOf

You get this exception from the annotations property.

From Dashboard Body Structure and Syntax :

annotations

To include an alarm or annotation in the widget, specify an annotations array. For more information about the format, see Dashboard Widget Object: Annotation Properties . Use this parameter only for metric widgets.

Type: Object

Required: An alarm annotation is required only when the widget type is metric and metrics is not specified. A horizontal or vertical annotation is not required .

But, as you can see since you provided metrics you don't need to provide any annotation.

therefore, just remove the annotations property from the JSON.

Working code snippet:

$DashboardBody = @"
{
  "widgets": [
    {
      "type": "metric",
      "x": 0,
      "y": 0,
      "width": 10,
      "height": 10,
      "properties": {
        "region": "us-west-2",
        "metrics": [
          [
            "AWS/EC2",
            "CPUUtilization",
            "InstanceId",
            "i-04c3216xyz"
          ]
        ],
        "view": "timeSeries",
        "stacked": false,
        "title": "server01 CPU",
        "legend": {
          "position": "right"
        }
      }
    },
    {
      "type": "metric",
      "x": 0,
      "y": 10,
      "width": 10,
      "height": 10,
      "properties": {
        "region": "us-west-2",
        "metrics": [
          [
            "AWS/EBS",
            "VolumeReadOps",
            "VolumeId",
            "vol-0b1ab41abc"
          ],
          [
            "AWS/EBS",
            "VolumeWriteOps",
            "VolumeId",
            "vol-0b1ab41abc"
          ]
        ],
        "view": "timeSeries",
        "stacked": false,
        "title": "server01 disk01 IOPs",
        "legend": {
          "position": "right"
        }
      }
    }
  ]
}
"@


Write-CWDashboard -DashboardName 'test' -DashboardBody $DashboardBody;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM