Windows サーバの EC2 に対してカスタムメトリクスの取得設定をした。
https://dev.classmethod.jp/cloud/aws/windows-server-runcommand-custom-metrics/
IAM ロール作成
対象の EC2 に割り当て
runcommand から json 実行
{
"EngineConfiguration": {
"PollInterval": "00:00:15",
"Components": [
{
"Id": "MemoryAvailableMegabytes",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "Memory",
"CounterName": "Available MBytes",
"InstanceName": "",
"MetricName": "MemoryAvailable",
"Unit": "Megabytes",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}"
}
},
{
"Id": "MemoryUtilization",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "Memory",
"CounterName": "% Committed Bytes in Use",
"InstanceName": "",
"MetricName": "MemoryUtilization",
"Unit": "Percent",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}"
}
},
{
"Id": "MonitoringFreeSpaceC",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "LogicalDisk",
"CounterName": "% Free Space",
"InstanceName": "C:",
"MetricName": "DiskFreeC",
"Unit": "Percent",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}"
}
},
{
"Id": "CloudWatchLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"AccessKey": "",
"SecretKey": "",
"Region": "us-east-1",
"LogGroup": "Default-Log-Group",
"LogStream": "{instance_id}"
}
},
{
"Id": "CloudWatch",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":
{
"AccessKey": "",
"SecretKey": "",
"Region": "ap-northeast-1",
"NameSpace": "★★★カスタムメトリクス名を入れる★★★"
}
}
],
"Flows": {
"Flows":
[
"(MonitoringFreeSpaceC,MemoryAvailableMegabytes,MemoryUtilization),CloudWatch"
]
}
}
}
注意として、カスタムメトリクスは削除ができない。
以上です。