LoginSignup
0
0

【AWS】CloudWatchAgentインストール手順_Windows

Posted at

CloudWatchAgentとは

EC2にインストールすることで、デフォルトでは収集できないメモリ、ディスク、プロセスなどの情報がメトリクスで収集可能となる。

参考:ユーザーガイド-CloudWatch エージェントを使用してメトリクス、ログ、トレースを収集する

参考:CloudWatch エージェントにより収集されるメトリクス

インストール手順

参考:コマンドラインを使用した CloudWatch エージェントのインストール

  1. CloudWatch エージェントパッケージをダウンロード

Invoke-WebRequest -Uri "https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi" -OutFile "amazon-cloudwatch-agent.msi" msiexec /i amazon-cloudwatch-agent.msi

  1. CloudWatch エージェントパッケージをインストール

msiexec /i amazon-cloudwatch-agent.msi

  1. 設定ウィザードの起動

cd "C:\Program Files\Amazon\AmazonCloudWatchAgent"

.\amazon-cloudwatch-agent-config-wizard.exe

設定ウィザードを起動すると以下の質問が表示されるので、キーボードで数字を入力後Enterキーを押下する。
数字を入力せずにEnterキーを押下することでdefault choiceが選択される。

  • インストールを行うインスタンスのOS
On which OS are you planning to use the agent?
1. linux
2. windows
3. darwin
default choice: [1]:
  • インストール先のサーバがEC2なのかオンプレなのか
Trying to fetch the default region based on ec2 metadata...
Are you using EC2 or On-Premises hosts?
1. EC2
2. On-Premises
default choice: [1]:
Which user are you planning to run the agent?
1. root
2. cwagent
3. others
default choice: [1]:
Do you want to turn on StatsD daemon?
1. yes
2. no
default choice: [1]:
Do you want to monitor metrics from CollectD? WARNING: CollectD must be installed or the Agent will fail to start
1. yes
2. no
default choice: [1]:
  • ホストのメトリクスを収集するか否か
Do you want to monitor any host metrics? e.g. CPU, memory, etc.
1. yes
2. no
default choice: [1]:
  • CPUをコア毎にモニタリングするか否か
Do you want to monitor cpu metrics per core?
1. yes
2. no
default choice: [1]:
  • ImageId, InstanceId, InstanceType, AutoScalingGroupNameを取得するか否か
Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName) into all of your metrics if the info is available?
1. yes
2. no
default choice: [1]:
  • メトリクスをInstanceIDで集約するか否か
Do you want to aggregate ec2 dimensions (InstanceId)?
1. yes
2. no
default choice: [1]:
  • メトリクスの収集頻度
Would you like to collect your metrics at high resolution (sub-minute resolution)? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output json file.
1. 1s
2. 10s
3. 30s
4. 60s
default choice: [4]:
Which default metrics config do you want?
1. Basic
2. Standard
3. Advanced
4. None
default choice: [1]:
  • これまでの設定値をJsonが表示されます。問題が無ければ1を選択
Current config as follows:
{
        "agent": {
                "metrics_collection_interval": 60,
                "run_as_user": "root"
~~省略~~
        }
}
    
Are you satisfied with the above config? Note: it can be manually customized after the wizard completes to add additional items.
1. yes
2. no
default choice: [1]:
  • 他の設定ファイルをインポートするか否か
Do you have any existing CloudWatch Log Agent (http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AgentReference.html) configuration file to import for migration?
1. yes
2. no
default choice: [2]:
  • ログファイルの収集を行うか否か
Do you want to monitor any log files?
1. yes
2. no
default choice: [1]:

yesにした場合[Log file path:][Log group name:][Log stream name:][Log Group Retention in days]をログに合わせて入力する。

  • X-rayの使用有無
Do you want the CloudWatch agent to also retrieve X-ray traces?
1. yes
2. no
default choice: [1]: 
  • これまでの設定値をJsonが表示されます(2回目)
Saved config file to /opt/aws/amazon-cloudwatch-agent/bin/config.json successfully.
Current config as follows:
{
        "agent": {
                "metrics_collection_interval": 60,
                "run_as_user": "root"
~~省略~~
        }
}
Please check the above content of the config.
The config file is also located at /opt/aws/amazon-cloudwatch-agent/bin/config.json.
Edit it manually if needed.
  • 設定をSSMパラメータストアに保存するか否か
Do you want to store the config in the SSM parameter store?
1. yes
2. no
default choice: [1]:

yesにした場合[パラメータストア名]][保存するリージョン][AWSクレデンシャル情報]を保存するパラメータストアに合わせて入力する。

CloudWatchAgent操作コマンド(Powershell)

起動

& $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -s -c file:"C:\Program Files\Amazon\AmazonCloudWatchAgent\config.json"

起動確認

& $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a status

停止

& $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a stop

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0