How can I monitor CloudWatch memory usage metrics for Elastic Beanstalk in a Windows environment?

Last updated: 2019-12-31

How do I monitor memory utilization with Amazon CloudWatch from my AWS Elastic Beanstalk environment in Windows?

Short Description

You can use Elastic Beanstalk configuration files (.ebextensions) to monitor memory utilization with CloudWatch for .NET on Windows Server with IIS.

Note: By default, the CloudWatch agent is installed on all Elastic Beanstalk Windows environments running platform versions 2.0.1 or newer.


Set up your .ebextensions directory

In the root of your application bundle, create a hidden directory named .ebextensions.

Example application source bundle:

  |-- Content
  |-- .ebextensions
  |-- archive.xml
  `-- systemInfo.xml

Create and store configuration files and PowerShell scripts

Create a file called 01_cw-memory-config.config inside the .ebextension folder that you created as part of the application source bundle.

Example configuration file:

  "C:\\Program Files\\Amazon\\AmazonCloudWatchAgent\\cw-memory-config.json":
    content: |
          "metrics": {
              "append_dimensions": {
                  "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
                  "ImageId": "${aws:ImageId}",
                  "InstanceId": "${aws:InstanceId}",
                  "InstanceType": "${aws:InstanceType}"
              "metrics_collected": {
                  "Memory": {
                      "measurement": [
                          "% Committed Bytes In Use"
                      "metrics_collection_interval": 10

    command: powershell.exe cd 'C:\Program Files\Amazon\AmazonCloudWatchAgent'; powershell.exe -ExecutionPolicy Bypass -File ./amazon-cloudwatch-agent-ctl.ps1 -a append-config -m ec2 -c file:cw-memory-config.json -s; powershell.exe -ExecutionPolicy Bypass -File ./amazon-cloudwatch-agent-ctl.ps1 -a start; exit

The 01_cw-memory-config.config configuration file does the following:

  • Defines the metrics that the CloudWatch agent collects and pushes to CloudWatch
  • Collects the metrics for percentage of memory used

Note: For a list of supported CloudWatch metrics for Amazon Elastic Compute Cloud (Amazon EC2), see CloudWatch Built-In Metrics.

The files section includes the CloudWatch configuration JSON content that defines which metric to push to CloudWatch. The container_commands section runs commands after the application bundle is unpacked on the Amazon EC2 instance.

Example application source bundle with 01_cw-memory-config.config file:

|-- Content
|-- .ebextensions
|   |--01_cw-memory-config.config
|-- archive.xml
`-- systemInfo.xml

Deploy your application and view your metrics

1.    Deploy your updated Elastic Beanstalk application.

2.    To see your memory utilization metrics, open the CloudWatch console, and then choose Metrics in the navigation pane. You can see your metrics in the custom namespace labeled CWAgent.

Did this article help you?

Anything we could improve?

Need more help?