I want to monitor memory use with Amazon CloudWatch from my AWS Elastic Beanstalk environment in Windows.
You 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.
Create the .ebextensions directory
- In 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.
Create and save configuration file in the .ebextensions directory
- Create 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.
"% Committed Bytes In Use"
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-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.
Deploy your application and view your metrics
- Deploy 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.