无法使用自定义CloudWatch指标监视Windows实例的可用磁盘空间

时间:2017-01-06 18:33:49

标签: amazon-web-services amazon-ec2 amazon-cloudwatch

我创建了一个用户并向他添加了以下 内联策略 。它读下面的内容:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowAccessToSSM",
            "Effect": "Allow",
            "Action": [
                "cloudwatch:PutMetricData",
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:DescribeLogGroups",
                "logs:DescribeLogStreams",
                "logs:PutLogEvents"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

然后,我通过对.json文件进行以下更改,成功监控了 可用内存

...
{
      "Id": "PerformanceCounterMemory",
      "FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
      "Parameters": {
           "CategoryName": "Memory",
           "CounterName": "Available MBytes",
           "InstanceName": "",
           "MetricName": "Memory",
           "Unit": "Megabytes",
           "DimensionName": "InstanceId",
           "DimensionValue": "{instance_id}"
       }
},

{
      "Id": "CloudWatch",
      "FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
      "Parameters":{               
           "AccessKey": "xxxxxxxxxxxxxxxxxxx",
           "SecretKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
           "Region": "us-east-1",
           "NameSpace": "Windows/Demo"
       }
}

"Flows": {
            "Flows": 
            [
                "PerformanceCounterMemory,CloudWatch"
            ]
        }
...

以这种方式编辑该文件后,我在 ec2ConfigSettings 中启用了 CloudWatch Integration 复选框。

接下来,我重新启动了 ec2Config Amazon SSM代理 服务。

成功地,我可以在CloudWatch控制台中看到内存指标。

现在,我想考虑监控可用的 磁盘空间

为此,我已将此部分添加到我的.json文件中:

        {
            "Id": "PerformanceCounterDisk",
            "FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
            "Parameters": {
                "CategoryName": "LogicalDisk",
                "CounterName": "% Free Space",
                "InstanceName": "C:",
                "MetricName": "FreeDisk",
                "Unit": "Percent",
                "DimensionName": "InstanceId",
                "DimensionValue": "{instance_id}"
            }
        },

    "Flows": {
        "Flows": 
        [
            "(PerformanceCounterMemory,PerformanceCounterDisk),CloudWatch"
        ]
    }

执行此操作后,我重新启动了 ec2Config Amazon SSM代理 服务,但我可以在我的命名空间下看不到这个指标。仅显示内存而不显示磁盘空间。

我犯了什么错误?

1 个答案:

答案 0 :(得分:1)

我刚刚改变了

"InstanceName": "C:",

"InstanceName": "_Total",

过了一段时间,出现了免费磁盘指标。