Search code examples
amazon-web-servicesamazon-cloudfrontamazon-cloudwatch

Cannot add widget to AWS Cloudwatch Dashboard


I am trying to configure an existing AWS Dashboard with adding one new widget.

In Amazon Kinesis / Analytics application / Streaming application I click on the graphs 'View in metrics" of which I would like to add to my dashboard metrics

In the next screen I click Actions / Add to dashboard addtodashboard after selecting my dashboard I click add, and then I can see my dashboard with the chart: dashboard-preview

However, if I click on "Save" I get the following error:

There was an error while trying to save your dashboard:
The dashboard body is invalid, there are 6 validation errors: [ 
{ "dataPath": "/widgets/5/properties/metrics/0", "message": "Should NOT have more than 4 items" }, 
{ "dataPath": "/widgets/5/properties/metrics/1", "message": "Should NOT have more than 4 items" },
{ "dataPath": "/widgets/5/properties/yAxis/left", "message": "Should be null" },
{ "dataPath": "/widgets/5/properties/yAxis/left", "message": "Should match some schema in anyOf" }, 
{ "dataPath": "/widgets/5/properties/yAxis/right", "message": "Should be null" }, 
{ "dataPath": "/widgets/5/properties/yAxis/right", "message": "Should match some schema in anyOf" } ]

I am totally clueless, as I did not enter anything manually, all I done was just clicking on the menu items. What is the problem here? I don't even understand the error messages even. I have 4 logs, and 1 chart already on the screen, this would be the 6th item if that is important.

Update: adding the source code of the template (I censored some sensitive information with "......."):

{
    "widgets": [
        {
            "height": 6,
            "width": 24,
            "y": 12,
            "x": 0,
            "type": "log",
            "properties": {
                "query": "SOURCE '/aws/kinesis-analytics/.......' | fields @timestamp, message | filter applicationARN like /arn:aws:kinesisanalytics:eu-west-1:......./| filter messageType = \"ERROR\"| sort @timestamp desc",
                "region": "eu-west-1",
                "title": "Error log (last 1000 records)",
                "view": "table"
            }
        },
        {
            "height": 6,
            "width": 24,
            "y": 6,
            "x": 0,
            "type": "log",
            "properties": {
                "query": "SOURCE '/aws/kinesis-analytics/.......' | fields @timestamp, message | filter applicationARN like /arn:aws:kinesisanalytics:eu-west-1:......./|  sort @timestamp desc",
                "region": "eu-west-1",
                "title": "Full log (last 1000 records)",
                "view": "table"
            }
        },
        {
            "height": 6,
            "width": 24,
            "y": 18,
            "x": 0,
            "type": "log",
            "properties": {
                "query": "SOURCE '/aws/kinesis-analytics/.......' | fields @timestamp, message | filter applicationARN like /arn:aws:kinesisanalytics:eu-west-1:......./| filter message like / OEE Data Streaming app v / | sort @timestamp desc",
                "region": "eu-west-1",
                "title": "Version - works only right after deployment, othervise look at the name of the jar file :) ",
                "view": "table"
            }
        },
        {
            "height": 6,
            "width": 24,
            "y": 0,
            "x": 0,
            "type": "log",
            "properties": {
                "query": "SOURCE '/aws/kinesis-analytics/.......' | fields @timestamp, message | filter applicationARN like /arn:aws:kinesisanalytics:eu-west-1:338785721659:.......") | sort @timestamp desc",
                "region": "eu-west-1",
                "stacked": false,
                "title": "OEE app inside logs",
                "view": "table"
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 24,
            "x": 0,
            "type": "metric",
            "properties": {
                "region": "eu-west-1",
                "yAxis": {
                    "left": {
                        "min": 0
                    }
                },
                "metrics": [
                    [ "AWS/Kinesis", "GetRecords.Records", "StreamName", ".......", { "id": "m3", "visible": true } ]
                ],
                "stat": "Sum",
                "title": "GetRecords - .......",
                "start": "-PT3H",
                "end": "P0D",
                "view": "timeSeries",
                "stacked": false
            }
        }
    ]
}

and if I try to add the uptime widget, it's code is this :

 {
            "type": "metric",
            "x": 6,
            "y": 24,
            "width": 6,
            "height": 6,
            "properties": {
                "region": "eu-west-1",
                "yAxis": {
                    "left": {
                        "min": 0,
                        "stat": "Maximum",
                        "showUnits": false
                    },
                    "right": {
                        "min": 0,
                        "stat": "Maximum",
                        "showUnits": false
                    }
                },
                "metrics": [
                    [ "AWS/KinesisAnalytics", "uptime", "Application", "...", { "yAxis": "left", "label": "uptime", "stat": "Maximum", "showUnits": false } ],
                    [ ".", "fullRestarts", ".", ".", { "yAxis": "right", "label": "fullRestarts", "stat": "Maximum", "showUnits": false } ]
                ],
                "stat": "Maximum",
                "title": "Uptime (Milliseconds) - Maximum",
                "start": "-PT3H",
                "end": "P0D",
                "view": "timeSeries",
                "stacked": false
            }
        }

but I cannot save it now with the error message I described earlier.


Solution

  • Looks like the properties on axis definition and metric definition are mixed up.

    Axis should not have the stat property: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html#CloudWatch-Dashboard-Properties-YAxis-Properties-Format

    Metric definition should not have the showUnits property: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html#CloudWatch-Dashboard-Properties-Rendering-Object-Format

    Try removing the stat property from both left and right axis definition. Also remove the showUnits property from the metrics definition (that should only be on the axis definitions).

    If this was generated automatically, then it looks like a bug in the console.