~~NOCACHE~~ ## CloudWatchAgentのインストール-Windows Windows2019を例にインストール手順を記載します。 ### インストール https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html ### CloudWatchAgentのインストール 下記をダウンロードして実行します。 https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi ### コマンドメモ #### Windows cd "C:\Program Files\Amazon\AmazonCloudWatchAgent" .\amazon-cloudwatch-agent-config-wizard.exe # EC2 .\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:config.json #「-s」はcloudwatch-agentの停止/開始するオプション .\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c ssm:AmazonCloudWatch-xxxxx .\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a stop .\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a status .\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a start # オンプレ .\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m onPremise -c file:config.json #「-s」はcloudwatch-agentの停止/開始するオプション .\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m onPremise -c ssm:AmazonCloudWatch-xxxxx .\amazon-cloudwatch-agent-ctl.ps1 -m onPremise -a stop .\amazon-cloudwatch-agent-ctl.ps1 -m onPremise -a status .\amazon-cloudwatch-agent-ctl.ps1 -m onPremise -a start ### デフォルト参照先[C:\Users\Administrator\.aws]配下の資格情報を読み込んでくれない場合の対処法 %%C:\ProgramData\Amazon\AmazonCloudWatchAgent\common-config.toml%%を編集 ###変更前### # [credentials] # shared_credential_profile = "{profile_name}" # shared_credential_file = "{file_name}" ###変更後### [credentials] shared_credential_profile = "default" # shared_credential_file = "{file_name}" ### イベントログ #### event_nameの指定 監視したいイベントログの[プロパティ]から[フルネーム]の値を指定する。 ### ログレベル ^ ULS レベル名 ^ レベル ID ^ イベント ログでの表示 ^ 説明 ^ | Critical | 30 | 重大 | システム管理者がすぐに対処する必要があるイベント。\\ 一般的には、システムまたはアプリケーションなど、グローバル (システム全体) レベルで指定されます。\\ また、アプリケーションまたはシステムが、失敗あるいは停止したことを示すこともできます。 | | Error | 40 | エラー | 問題を示すイベント。ただし、このカテゴリのイベントはすぐに対処する必要はありません。 | | Warning | 50 | 警告 | 潜在的な問題について事前に警告するイベント。実際のエラーに対する応答ではありませんが、\\ コンポーネントまたはアプリケーションが理想的な状態ではないこと、\\ また、さらなるアクションを実行すると重大なエラーにつながる可能性があることを警告します。 | | Information | 80 | 情報 | 重大ではない情報を管理者に提供するイベント。"参考までに" というメモと同様の役割を果たします。 | | Verbose | 100 | 情報 | 進行状況または成功のメッセージなど、状態に関する詳細情報です。 | ### wizard #### メトリクス関連 ============================================================= = Welcome to the AWS CloudWatch Agent Configuration Manager = ============================================================= # OSを選択します。 On which OS are you planning to use the agent? 1. linux 2. windows 3. darwin default choice: [2]: # 環境を選択します。 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: [2]: # StatsDの使用を選択します。https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-custom-metrics-statsd.html Please make sure the credentials and region set correctly on your hosts. Refer to http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html Do you want to turn on StatsD daemon? 1. yes 2. no default choice: [1]: # StatsDのポートを指定します。 Which port do you want StatsD daemon to listen to? default choice: [8125] # StatsDの収集間隔を選択します。 What is the collect interval for StatsD daemon? 1. 10s 2. 30s 3. 60s default choice: [1]: # StatsDのメトリクス間隔を選択します。 What is the aggregation interval for metrics collected by StatsD daemon? 1. Do not aggregate 2. 10s 3. 30s 4. 60s default choice: [4]: # メトリクス収集にCollectDを利用するか選択します。 Do you want to monitor metrics from CollectD? 1. yes 2. no default choice: [1]: # CPUやメモリのメトリクスを収集するか選択します。 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? Additional CloudWatch charges may apply. 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]: # メトリクスの事前定義されたメトリクスセットを選択します。https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html Which default metrics config do you want? 1. Basic 2. Standard 3. Advanced 4. None default choice: [1]: # 上記設定で良いかの確認です。 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 want to monitor any log files? 1. yes 2. no default choice: [1]: # ファイルパスを指定します。 Log file path: # ロググループ名を指定します。 Log group name: default choice: [.] # ログストリーム名を指定します。 Log stream name: default choice: [{instance_id}] # 追加でモニターするログがあるかの確認です。 Do you want to specify any additional log files to monitor? 1. yes 2. no default choice: [1]: # モニターするWindowsイベントログがあるかの確認です。 Do you want to monitor any Windows event log? 1. yes 2. no default choice: [1]: # Windowsイベントログを指定します。[application]や[security]も指定できます。 Windows event log name: default choice: [System] # ULS レベル名の指定です。 Do you want to monitor VERBOSE level events for Windows event log System ? 1. yes 2. no default choice: [1]: Do you want to monitor INFORMATION level events for Windows event log System ? 1. yes 2. no default choice: [1]: Do you want to monitor WARNING level events for Windows event log System ? 1. yes 2. no default choice: [1]: Do you want to monitor ERROR level events for Windows event log System ? 1. yes 2. no default choice: [1]: Do you want to monitor CRITICAL level events for Windows event log System ? 1. yes 2. no default choice: [1]: # ロググループ名を指定します。 Log group name: default choice: [System] # ログストリーム名を指定します。 Log stream name: default choice: [{hostname}] # ログストリームに記録する形式を選択します。 In which format do you want to store windows event to CloudWatch Logs? 1. XML: XML format in Windows Event Viewer 2. Plain Text: Legacy CloudWatch Windows Agent (SSM Plugin) Format default choice: [1]: # 追加でモニターするWindowsイベントログがあるかの確認です。 Do you want to specify any additional Windows event log to monitor? 1. yes 2. no default choice: [1]: #### パラメータストア関連 # /opt/aws/amazon-cloudwatch-agent/bin/config.jsonにコンフィグを保存しました。 Please check the above content of the config. The config file is also located at config.json. Edit it manually if needed. # パラメータストアに保存するかの確認です。 Do you want to store the config in the SSM parameter store? 1. yes 2. no default choice: [1]: # パラメータストアに保存するパラメータ名の確認です。※AmazonCloudWatch-XXXX形式で入力してください。 What parameter store name do you want to use to store your config? (Use 'AmazonCloudWatch-' prefix if you use our managed AWS policy) default choice: [AmazonCloudWatch-windows] # パラメータストアのリージョンの確認です。 Which region do you want to store the config in the parameter store? default choice: [ap-northeast-1] # Credentialの確認です。 Which AWS credential should be used to send json config to parameter store? 1. XXXXXXXXXXXXXXXXXXXX(From SDK) 2. Other default choice: [1]: {{tag>AWS CloudWatchAgent CloudWatch}}