title: Monitoring memory usage in AWS CloudWatch for Windows instance
body: <p>By default, memory usage isn’t monitored by CloudWatch. So I tried to add it to my Windows instance in AWS using <a href="http://blog.krishnachaitanya.ch/2016/03/monitor-ec2-memory-usage-using-aws.html" rel="noreferrer">these instructions</a>.</p>
  
  <p>This is what I did:</p>
  
  <ol>
  <li><p>I created a user named <code>custom-metrics-user</code>. Then I stored the access and secret key.</p></li>
  <li><p>I created and attached an Inline Policy to the user. it looks like this: </p></p>
  
  <pre class="lang-json prettyprint-override"><code>{ 
    "Version": "2012-10-17", 
    "Statement": [ 
      { 
        "Effect": "Allow", 
        "Action": ["cloudwatch:PutMetricData", "cloudwatch:GetMetricStatistics", "cloudwatch:ListMetrics", "ec2:DescribeTags"], 
        "Resource": "*" 
      } 
    ] 
  }
  </code></pre>
  
  <p></p></p></li>
  <li><p>I launched a Windows Instance [2012 R2 Base AMI]. After accessing the instance through RDP, I found that the <code>AWS.EC2.Windows.CloudWatch.json</code> file is already present. </p></li>
  <li><p>I changed that <code>.json</code> file accordingly. After changing it, it looks like this: </p></p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "EngineConfiguration": {
          "PollInterval": "00:00:15",
          "Components": [
              {
                  "Id": "ApplicationEventLog",
                  "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                  "Parameters": {
                      "LogName": "Application",
                      "Levels": "1"
                  }
              },
              {
                  "Id": "SystemEventLog",
                  "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                  "Parameters": {
                      "LogName": "System",
                      "Levels": "7"
                  }
              },
              {
                  "Id": "SecurityEventLog",
                  "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                  "Parameters": {
                  "LogName": "Security",
                  "Levels": "7"
                  }
              },
              {
                  "Id": "ETW",
                  "FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
                  "Parameters": {
                      "LogName": "Microsoft-Windows-WinINet/Analytic",
                      "Levels": "7"
                  }
              },
              {
                  "Id": "IISLog",
                  "FullName": "AWS.EC2.Windows.CloudWatch.IisLog.IisLogInputComponent,AWS.EC2.Windows.CloudWatch",
                  "Parameters": {
                      "LogDirectoryPath": "C:\\inetpub\\logs\\LogFiles\\W3SVC1"
                  }
              },
              {
                  "Id": "CustomLogs",
                  "FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
                  "Parameters": {
                      "LogDirectoryPath": "C:\\CustomLogs\\",
                      "TimestampFormat": "MM/dd/yyyy HH:mm:ss",
                      "Encoding": "UTF-8",
                      "Filter": "",
                      "CultureName": "en-US",
                      "TimeZoneKind": "Local"
                  }
              },
              {
                  "Id": "PerformanceCounter",
                  "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": "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": "AKIAIK2U6EU675354BQ",
                      "SecretKey": "nPyk9ntdwW0y5oaw8353fsdfTi0e5/imx5Q09vz",
                      "Region": "us-east-1",
                      "NameSpace": "System/Windows"
                  }
              }
          ],
          "Flows": {
              "Flows": 
              [
                  "PerformanceCounter,CloudWatch"
              ]
          }
      } 
  }
  </code></pre>
  
  <p></p></p></li>
  <li><p>I enabled CloudWatch Logs integration under EC2ConfigSettings.</p></li>
  <li><p>I restarted the EC2Config Service.</p></li>
  </ol>
  
  <p>I got no errors but the Memory metric isn't being shown in the Cloud Watch console. The blog says to wait for 10-15 minutes for the metric to appear, but it has already been an hour since I have done it. What’s going wrong?</p>