LoginSignup
2
1

More than 5 years have passed since last update.

CloudWatchカスタムメトリクス追加方法(ディスク、メモリ)

Last updated at Posted at 2017-07-26

やること

AWSのCloudWatchは、デフォルトだとディスクとメモリ使用率を見ることができません。
そこで利用するのがカスタムメトリクスです。
ディスクとメモリのカスタムメトリクスを追加します。

前提

  • インスタンスに、EC2FullAccessとCloudWatchFullAccessの権限を持ったIAMロールを関連づけている。(推奨)
  • もしくは、上記権限を持ったユーザがおり、アクセスキーとシークレットキーを用意している。(非推奨)

手順

1.対象サーバへログインする

2.スクリプトのインストール

# yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA
# curl http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip -O

3.圧縮ファイルの解凍と圧縮ファイルの削除

# unzip CloudWatchMonitoringScripts-1.2.1.zip
# rm CloudWatchMonitoringScripts-1.2.1.zip

4.crontabへのスクリプト実行設定

# crontab -e

 以下の内容を記述する。
 今回は、5分に1回の実行に設定する。

●IAMロール適用バージョン(推奨)
*/5 * * * * ~/aws-scripts-mon/mon-put-instance-data.pl  --mem-util --disk-space-util --disk-path=/ --from-cron

●アクセスキーとシークレットキーを記載(非推奨)
*/5 * * * * ~/aws-scripts-mon/mon-put-instance-data.pl  --mem-util --disk-space-util --disk-path=/ --from-cron --aws-access-key-id=アクセスキー --aws-secret-key=シークレットキー

5.crondの再起動

# systemctl restart crond

6.追加の確認
 AWSのコンソール画面で、CloudWatchを選択し、DiskSpaceUtilizationが追加されていることを確認する。

参考URL
http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/mon-scripts.html#using_put_script

2
1
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
2
1