How to monitor free disk space at AWS EC2 with Cloud Watch in windows

Misha Zaslavsky picture Misha Zaslavsky · May 25, 2016 · Viewed 22.4k times · Source

I want to make alarm in case that there is 10% left in my disk space.

I read some articles of how monitoring free disk space with Cloud Watch but I think it seems to be only for linux.

Do you have any solution for monitoring free disk space for windows?

Thanks in advance.

Answer

Simon Hutchison picture Simon Hutchison · Apr 24, 2017

This is how to configure a Windows 2016 EC2 instance to report free disk space (or any other performance counter on your server)

  • Download a sample AWS.EC2.Windows.CloudWatch.json file. This is where I found one. https://s3.amazonaws.com/ec2-downloads-windows/CloudWatchConfig/AWS.EC2.Windows.CloudWatch.json

  • Copy the sample AWS.EC2.Windows.CloudWatch.json file on your Windows Server 2016 EC2 Instance here C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch\

  • Edit AWS.EC2.Windows.CloudWatch.json and set IsEnabled true

  • Add additional metrics as required. There is a sample one in the config for memory usage. Copy/paste this and alter the Metric name like this:

{
    "Id": "PerformanceCounterDisk",
    "FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
    "Parameters": {
        "CategoryName": "LogicalDisk",
        "CounterName": "% Free Space",
        "InstanceName": "C:",
        "MetricName": "FreeDiskPercentage",
        "Unit": "Percent",
        "DimensionName": "InstanceId",
        "DimensionValue": "{instance_id}"
    }
}
  • Run Powershell as administrator and run Restart-Service AmazonSSMAgent

  • New CloudWatch metrics appear almost instantly in AWS CloudWatch.

  • Configure AWS CloudWatch alarms as required.

Additionally, I made a short video with some tips on setting this up on Windows Server 2016.

https://www.youtube.com/watch?v=xKVrJJyG-4I

The following guide from AWS contains a step by step guide. http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/send_logs_to_cwl_instances.html#send_logs_cwl_configfile