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

3 分的閱讀內容
0

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

Short description

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:

  1. Create the .ebextensions directory.
  2. Create and save configuration file in the .ebextensions directory.
  3. 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.

Resolution

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.

~/workspace/my-application/
|-- Content
|-- .ebextensions
|  
|-- archive.xml
`-- systemInfo.xml

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.

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; 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.

~/workspace/my-application/
|-- Content
|-- .ebextensions
|   |--01_cw-memory-metrics.config
|  
|-- archive.xml
`-- systemInfo.xml

Deploy your application and view your metrics

  1. Deploy your updated Elastic Beanstalk application.
  2. 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.

AWS 官方
AWS 官方已更新 1 年前