🛠️

[AWS][CloudWatch] agent-config-wizardで問われたこと(Ubuntuの場合)

2021/05/02に公開

published_at: 2019-09-08


とある AWS EC2 インスタンスのディスク容量の監視を行うのに CloudWatch Agent を入れた。
ウィザードでのインストールを5回繰り返してすっかり慣れてサクサクやれたので、共有しておいても良いかな、と思い。

前提(環境)

パッケージのダウンロード・インストール

以下のコマンドで行いました。

# wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb

# sudo dpkg -i -E ./amazon-cloudwatch-agent.deb

問われたこと

起動

# sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
=============================================================
= Welcome to the AWS CloudWatch Agent Configuration Manager =
=============================================================

OSの種別

On which OS are you planning to use the agent?
1. linux
2. windows
default choice: [1]:

使うのがEC2かオンプレか

Are you using EC2 or On-Premises hosts?
1. EC2
2. On-Premises
default choice: [1]:

Agent を稼働させるユーザー

Which user are you planning to run the agent?
1. root
2. cwagent
3. others
default choice: [1]:

StatsD daemon を起動するか

Do you want to turn on StatsD daemon?
1. yes
2. no
default choice: [1]:

StatsD daemon のポート番号

Which port do you want StatsD daemon to listen to?
default choice: [8125]

メトリクスの収集間隔

What is the collect interval for StatsD daemon?
1. 10s
2. 30s
3. 60s
default choice: [1]:

メトリクスの集計間隔

What is the aggregation interval for metrics collected by StatsD daemon?
1. Do not aggregate
2. 10s
3. 30s
4. 60s
default choice: [4]:

収集したメトリクスを監視するか

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]:

利用可能なら全メトリクスにEC2の各諸元情報を加えるか

(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]:

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]:

どの(レベルの)既定の設定がよいか

(Basic・Standard・Advanced)

Which default metrics config do you want?
1. Basic
2. Standard
3. Advanced
4. None
default choice: [1]:

ここで設定のjsonが提示される (1)

ここまでの設定はOKか?

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]:

保存された設定のjsonが提示される (2)

Saved config file to /opt/aws/amazon-cloudwatch-agent/bin/config.json successfully.
Current config as follows:

(設定 json の内容)

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]:

パラメータストアの名前を何にするか

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-linux]

(入力受付)

Trying to fetch the default region based on ec2 metadata...

どのリージョンにパラメータストアを保存するか

Which region do you want to store the config in the parameter store?
default choice: [ap-northeast-1]

どのAWSクレデンシャルをパラメータストア保存に使うか

Which AWS credential should be used to send json config to parameter store?
1. ASIA4532EPFAAFKBTGXF(From SDK)
2. Other
default choice: [1]:

AWSクレデンシャルの入力

Please provide credentials to upload the json config file to parameter store.
AWS Access Key:
********************
AWS Secret Key:
****************************************
Successfully put config to parameter store (設定したパラメータストアの名前)
Program exits now.

CloudWatchAgentの起動

E! Error parsing /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml, open /usr/share/collectd/types.db: no such file or directory に遭遇したので以下の手順となった

# mkdir -p /usr/share/collectd/
# touch /usr/share/collectd/types.db

# sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s

Configuration validation second phase succeeded
Configuration validation succeeded
Created symlink from /etc/systemd/system/multi-user.target.wants/amazon-cloudwatch-agent.service to /etc/systemd/system/amazon-cloudwatch-agent.service.

関連情報

official

(un-official)

その他

インストールではないが、2点、困った。
とりあえずは、まあ、いいんですが。

https://twitter.com/sogaoh/status/1170746454433878016


https://twitter.com/sogaoh/status/1171103710287499265


Discussion