CloudWatch Dashboards: MSSQL用

MSSQLのEC2上のパフォーマンス計測用のダッシュボード。
移行のダウンタイム短縮等でモニタリングできるように使います。
今まで環境ごとにリソースIDを書いていましたが、変数で解決できそう。
環境固定で使いたい場合、variablesで定義している、defaultValueを各リソースIDに変更すればOK。

完成はこんな感じ。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2587098/f4041d75-6319-41e0-8af4-997bfe88abda.png)


```json:CloudWatchDashboards_MSSQL
{
    "variables": [
        {
            "type": "property",
            "property": "region",
            "inputType": "input",
            "id": "region",
            "label": "region",
            "defaultValue": "ap-northeast-1",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "AP-EC2-InstanceID",
            "inputType": "input",
            "id": "AP-EC2-InstanceID",
            "label": "AP-EC2-InstanceID",
            "defaultValue": "i-xxxxxxx",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "db-ebs-dblog1",
            "inputType": "input",
            "id": "DB-EBS-DBLOG1",
            "label": "DB-EBS-DBLOG1",
            "defaultValue": "vol-xxxxxxx",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "db-ebs-dbdata1",
            "inputType": "input",
            "id": "DB-EBS-DBDATA1",
            "label": "DB-EBS-DBDATA1",
            "defaultValue": "vol-xxxxxxx",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "db-ebs-dbdata2",
            "inputType": "input",
            "id": "DB-EBS-DBDATA2",
            "label": "DB-EBS-DBDATA2",
            "defaultValue": "vol-xxxxxxx",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "db-ebs-dbdata3",
            "inputType": "input",
            "id": "DB-EBS-DBDATA3",
            "label": "DB-EBS-DBDATA3",
            "defaultValue": "vol-xxxxxxx",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "db-ebs-dbdata4",
            "inputType": "input",
            "id": "DB-EBS-DBDATA4",
            "label": "DB-EBS-DBDATA4",
            "defaultValue": "vol-xxxxxxx",
            "visible": true
        },
        {
            "type": "pattern",
            "pattern": "db-ebs-tempdb",
            "inputType": "input",
            "id": "DB-EBS-TEMPDB",
            "label": "DB-EBS-TEMPDB",
            "defaultValue": "vol-xxxxxxx",
            "visible": true
        }
    ],
    "widgets": [
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 0,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EC2", "CPUUtilization", "InstanceId", "AP-EC2-InstanceID", { "stat": "Average", "id": "m0" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": false,
                "title": "DB - CPUUtilization",
                "region": "ap-northeast-1",
                "yAxis": {
                    "left": {
                        "max": 100,
                        "min": 0
                    }
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 0,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeReadBytes", "VolumeId", "db-ebs-dblog1", { "id": "m1", "label": "dblog1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m2", "label": "dbdata1r" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m3", "label": "dbdata2r" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m4", "label": "dbdata3r" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m5", "label": "dbdata4r" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdbr" } ],
                    [ ".", "VolumeWriteBytes", ".", "db-ebs-dblog1", { "id": "m11", "label": "dblog1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m12", "label": "dbdata1w" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m13", "label": "dbdata2w" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m14", "label": "dbdata3w" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m15", "label": "dbdata4w" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdbw" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": true,
                "title": "DB - EC2throughput",
                "region": "ap-northeast-1",
                "stat": "Sum",
                "annotations": {
                    "horizontal": [
                        {
                            "label": "2375MB/s",
                            "value": 149422080000
                        },
                        {
                            "label": "1500MB/s",
                            "value": 94371840000
                        },
                        {
                            "label": "1000MB/s",
                            "value": 62914560000
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 6,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeReadOps", "VolumeId", "db-ebs-dblog1", { "id": "m1", "label": "dblog1", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m2", "label": "dbdata1r", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m3", "label": "dbdata2r", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m4", "label": "dbdata3r", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m5", "label": "dbdata4r", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdbr", "region": "ap-northeast-1" } ],
                    [ ".", "VolumeWriteOps", ".", "db-ebs-dblog1", { "id": "m11", "label": "dblog1", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m12", "label": "dbdata1w", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m13", "label": "dbdata2w", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m14", "label": "dbdata3w", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m15", "label": "dbdata4w", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdbw", "region": "ap-northeast-1" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": true,
                "title": "DB - EC2IOPS",
                "region": "ap-northeast-1",
                "stat": "Sum",
                "annotations": {
                    "horizontal": [
                        {
                            "label": "80000IOPS",
                            "value": 4800000
                        },
                        {
                            "label": "55000IOPS",
                            "value": 3300000
                        },
                        {
                            "label": "16000IOPS",
                            "value": 960000
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 12,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeWriteBytes", "VolumeId", "db-ebs-dblog1", { "id": "m1", "label": "dblog1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m2", "label": "dbdata1" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m3", "label": "dbdata2" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m4", "label": "dbdata3" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m5", "label": "dbdata4" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdb" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": false,
                "title": "DB - VolumeWriteBytes",
                "region": "ap-northeast-1",
                "stat": "Sum",
                "yAxis": {
                    "left": {
                        "min": 0,
                        "showUnits": true
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "1000MB/s",
                            "value": 62914560000
                        },
                        {
                            "label": "500MB/s",
                            "value": 31457280000
                        },
                        {
                            "label": "300MB/s",
                            "value": 18874368000
                        },
                        {
                            "label": "125MB/s",
                            "value": 7864320000
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 6,
            "x": 18,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeWriteOps", "VolumeId", "db-ebs-dblog1", { "id": "m1", "label": "dblog1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m2", "label": "dbdata1" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m3", "label": "dbdata2" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m4", "label": "dbdata3" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m5", "label": "dbdata4" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdb" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": false,
                "title": "DB - VolumeWriteOps",
                "region": "ap-northeast-1",
                "stat": "Sum",
                "yAxis": {
                    "left": {
                        "min": 0,
                        "label": "",
                        "showUnits": true
                    },
                    "right": {
                        "min": 0,
                        "label": "",
                        "showUnits": false
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "16000IOPS",
                            "value": 960000
                        },
                        {
                            "label": "8000IOPS",
                            "value": 480000
                        },
                        {
                            "label": "3000IOPS",
                            "value": 180000
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 6,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeQueueLength", "VolumeId", "db-ebs-dblog1", { "stat": "Average", "id": "m1", "label": "dblog1", "region": "ap-northeast-1" } ],
                    [ "...", "db-ebs-dbdata1", { "stat": "Average", "id": "m2", "label": "dbdata1" } ],
                    [ "...", "db-ebs-dbdata2", { "stat": "Average", "id": "m3", "label": "dbdata2" } ],
                    [ "...", "db-ebs-dbdata3", { "stat": "Average", "id": "m4", "label": "dbdata3" } ],
                    [ "...", "db-ebs-dbdata4", { "stat": "Average", "id": "m5", "label": "dbdata4" } ],
                    [ "...", "db-ebs-tempdb", { "stat": "Average", "id": "m6", "label": "tempdb" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": false,
                "title": "DB - VolumeQueueLength",
                "region": "ap-northeast-1",
                "yAxis": {
                    "left": {
                        "min": 0
                    }
                },
                "annotations": {
                    "horizontal": [
                        {
                            "label": "1",
                            "value": 1
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 12,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeReadBytes", "VolumeId", "db-ebs-dblog1", { "id": "m1", "label": "dblog1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m2", "label": "dbdata1" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m3", "label": "dbdata2" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m4", "label": "dbdata3" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m5", "label": "dbdata4" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdb" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": false,
                "title": "DB - VolumeReadBytes",
                "region": "ap-northeast-1",
                "stat": "Sum",
                "annotations": {
                    "horizontal": [
                        {
                            "label": "1000MB/s",
                            "value": 62914560000
                        },
                        {
                            "label": "500MB/s",
                            "value": 31457280000
                        },
                        {
                            "label": "300MB/s",
                            "value": 18874368000
                        },
                        {
                            "label": "125MB/s",
                            "value": 7864320000
                        }
                    ]
                }
            }
        },
        {
            "height": 6,
            "width": 6,
            "y": 0,
            "x": 18,
            "type": "metric",
            "properties": {
                "metrics": [
                    [ "AWS/EBS", "VolumeReadOps", "VolumeId", "db-ebs-dblog1", { "id": "m1", "label": "dblog1" } ],
                    [ "...", "db-ebs-dbdata1", { "id": "m2", "label": "dbdata1" } ],
                    [ "...", "db-ebs-dbdata2", { "id": "m3", "label": "dbdata2" } ],
                    [ "...", "db-ebs-dbdata3", { "id": "m4", "label": "dbdata3" } ],
                    [ "...", "db-ebs-dbdata4", { "id": "m5", "label": "dbdata4" } ],
                    [ "...", "db-ebs-tempdb", { "id": "m6", "label": "tempdb" } ]
                ],
                "legend": {
                    "position": "bottom"
                },
                "period": 60,
                "view": "timeSeries",
                "stacked": false,
                "title": "DB - VolumeReadOps",
                "region": "ap-northeast-1",
                "stat": "Sum",
                "annotations": {
                    "horizontal": [
                        {
                            "label": "16000IOPS",
                            "value": 960000
                        },
                        {
                            "label": "8000IOPS",
                            "value": 480000
                        },
                        {
                            "label": "3000IOPS",
                            "value": 180000
                        }
                    ]
                }
            }
        }
    ]
}
```