Windows 環境で Elastic Beanstalk の CloudWatch メモリ使用率メトリクスをモニタリングする方法を教えてください。

所要時間2分
0

Windows の AWS Elastic Beanstalk 環境から Amazon CloudWatch でメモリ使用率をモニタリングしたいと考えています。

簡単な説明

Elastic Beanstalk 設定ファイル (.ebextensions) をプロビジョニングして、次の操作を行って IIS を使用する Windows Server 上の CloudWatch for .NET でメモリ使用率をモニタリングできます。

  1. .ebextensions ディレクトリを作成します。
  2. 設定ファイルを作成し、.ebextensions ディレクトリに保存します。
  3. アプリケーションをデプロイし、メトリクスを表示します。

注: デフォルトでは、統合された CloudWatch エージェントは、プラットフォームバージョン 2.0.1 以降を実行するすべての Elastic Beanstalk Windows 環境にインストールされます。

解決方法

.ebextensions ディレクトリを作成する

  • アプリケーションバンドルのルートに、.ebextensions という名前の隠しディレクトリを作成します。

: この例は、プロジェクトディレクトリの最上位に .ebextensions ディレクトリがあるアプリケーションソースバンドル構造を示しています。

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

設定ファイルを作成し、.ebextensions ディレクトリに保存する

  • アプリケーションソースバンドルの一部として作成した .ebextensions ディレクトリ内に 01_cw-memory-metrics.config というファイルを作成します。

: この例では、CloudWatch エージェント設定ファイル - Metrics セクションを拡張しています。

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

01_cw-memory-metrics.config 設定ファイルは、次を実行します。

  • CloudWatch エージェントが収集して CloudWatch コンソール - Metricsにプッシュするメトリクスを定義します。
  • 使用メモリの割合メトリクスを収集します。
  • ファイルセクションには、CloudWatch に発行するメトリクスを定義する CloudWatch エージェント設定 JSON コンテンツが含まれています。
  • container_commands セクションでは、アプリケーションバンドルが Amazon Elastic Compute Cloud (Amazon EC2) インスタンスで解凍された後、コマンドを実行します。

注: Amazon EC2 でサポートされている CloudWatch メトリクス一覧については、「CloudWatch 組み込みメトリクス」を参照してください。

例: この例は、01_cw-memory-metrics.config を含むアプリケーションソースバンドル構造を示しています。

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

アプリケーションをデプロイし、メトリクスを表示する

  1. 更新した Elastic Beanstalk アプリケーションをデプロイします
  2. 以下のように、メモリ使用率メトリクスを確認します。
    • CloudWatch コンソールを開き、ナビゲーションペインで [Metrics] (メトリクス) を選択してから、[All metrics] (すべてのメトリクス) を選択します。メトリクスは、CWAgent というラベルのカスタム名前空間で確認できます。

AWS公式
AWS公式更新しました 1年前
コメントはありません

関連するコンテンツ