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

I want to monitor memory use with Amazon CloudWatch from my AWS Elastic Beanstalk environment in Windows.

Short descriptionYou can provision Elastic Beanstalk configuration files (.ebextensions) to monitor memory utilization with CloudWatch for .NET on Windows Server with IIS by doing the following:Create the .ebextensions directory.Create and save configuration file in the .ebextensions directory.Deploy your application and view your metrics.Note: By default, the unified CloudWatch agent is installed on all Elastic Beanstalk Windows environments running platform versions 2.0.1 or later.

ResolutionCreate the .ebextensions directoryIn the root of your application bundle, create a hidden directory named .ebextensions.Example: This example demonstrates an application source bundle structure with .ebextensions directory at the top level of the project directory.~/workspace/my-application/|-- Content|-- .ebextensions|  |-- archive.xml`-- systemInfo.xmlCreate and save configuration file in the .ebextensions directoryCreate a file called 01_cw-memory-metrics.config inside the .ebextensions directory that you created as part of the application source bundle.Example: This example extends the CloudWatch agent configuration file - Metrics section.files:  "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      }    }  }}container_commands:  01_set_config_and_reinitialize_cw_agent:    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; exitThe 01_cw-memory-metrics.config configuration file does the following:Defines the metrics that the CloudWatch agent collects and publishes to CloudWatch console - Metrics.Collects the metrics for percentage of memory used.The files section includes the CloudWatch agent configuration JSON content that defines which metric to publish to CloudWatch.The container_commands section runs commands after the application bundle is unpacked on the Amazon Elastic Compute Cloud (Amazon EC2) instance.Note: For a list of supported CloudWatch metrics for Amazon EC2, see CloudWatch built-in metrics.Example: This example demonstrates an application source bundle structure with 01_cw-memory-metrics.config included.~/workspace/my-application/|-- Content|-- .ebextensions|   |--01_cw-memory-metrics.config|  |-- archive.xml`-- systemInfo.xmlDeploy your application and view your metricsDeploy your updated Elastic Beanstalk application.Review the memory utilization metrics:Open the CloudWatch console, In the navigation pane, choose Metrics, and then choose All metrics.You can see your metrics in the custom namespace labeled CWAgent.