Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

amazon web services - Unable to monitor Free Disk Space for Windows Instances using Custom CloudWatch Metrics

I have created a user and added the following inline policy to him. It reads the below piece :

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

Then, I have successfully monitored the Available Memory by making the following changes to the .json file :

...
{
      "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"
            ]
        }
...

After editing that file this way, I enabled CloudWatch Integration checkbox in ec2ConfigSettings.

Next, I have restarted both ec2Config and Amazon SSM Agent Services.

Successfully, I could see the Memory metric in my CloudWatch console.

Now, I thought of monitoring the available Disk Space too.

For that, I have added this part to my .json file :

        {
            "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"
        ]
    }

After doing this, I have restarted both the ec2Config and Amazon SSM Agent Services, but I can't see this metric under my namespace. Only memory is being shown and not disk space.

What mistake have I done?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I just changed

"InstanceName": "C:",

to

"InstanceName": "_Total",

After sometime, the free disk metric showed up.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...