お久しぶりです。インフラ担当の柳瀬です。 みなさんAWSは好きですか?RDSは使っていますか?
私もRDSは構築の手間が省けて、大変お世話になっております。
スケールアップやディスク拡張も簡単に出来ますし、Multi-AZで対障害性も強化出来て素晴らしいですね! 『こうなったら監視なんて必要なさそうだぞ!!』って思えてしまいそうですが、そうはいきませんね。 RDSが素晴らしいサービスとはいえ、例えばディスク使用量が100%になってしまったらサービスダウンとなります。
Multi-AZを有効にしていても、めでたく共倒れとなります。
しかも、RDSはOSにログインする事が出来ずに、手慣れた監視クライアントをインストール出来ないのが悩みどころ。
今回のエントリでは、そんなRDSの監視をお手軽に、今すぐに出来る方法を一つご紹介したいと思います。
今回試用するツールは以下の2つとなり、それ以外に特別なものは必要ありません。
- Amazon CloudWatch
- Amazon Simple Notification Service(SNS)
また今回ご紹介する概要手順は以下の通りです。
- 稼働中のRDSに対してCloudwatchのAlermを設定
- 作成したAlermの状態になった場合のアクションとしてSNSメール通知を作成
- 動作確認
作業はManagement Consoleのみで完結します。 1)ManagementConsoleのCloudwatchタブからMetrics>RDSを選択します 2)監視対象RDSのFreeStorageSpaceを選択してCreate Alarmから作成をします 3)図のようにName、Description、不等式、閾値、時間を入力して次に進みます
※例ではディスクスペースが50GB以下の状態が5分継続した場合に警告が通知されます 4)Topicとして"Create New topic"を選択して図のように選択したら次に進みます
※ここで登録したメールアドレスにAmazon SNSを使用して警告通知されます 5)設定状況を確認して完了です。 6)設定完了後、指定したメールアドレスに以下のようなメールが届きます
※Confirm subscriptionというリンクを押下します
【AWS Notification - Subscription Confirtmation】
You have chosen to subscribe to the topic:
arn:aws:sns:ap-southeast-1:*************:alarm01
To confirm this subscription, click or visit the link below (If this was in error no action is necesary):
Confirm subscription
Please do not reply directly to this e-mail. If you wish to remove yourself from recieving all future SNS subscription confirmation requests please send email to sns-opt-out
7)動作確認用のデータを投入したら以下のようなメールが届きました
【[ALARM] Alarm "alarm01" in APAC - Singapore is now in state ALARM】 You are receiving this email because your Amazon CloudWatch Alarm "alarm01" in the APAC - Singapore region has entered the ALARM state, because "Threshold Crossed: 1 datapoint (49.703773696E9) was less than or equal to the threshold (50.0E9)." at "Tuesday 17 May, 2011 09:07:07 UTC" View this alarm in the AWS Management Console: https://console.aws.amazon.com/cloudwatch/home?region=ap-southeast-1#s=Alarms&alarm=alarm01 Alarm Details: - Name: alarm01 - Description: - State Change: INSUFFICIENT_DATA -> ALARM - Reason for State Change: Threshold Crossed: 1 datapoint (49.703773696E9) was less than or equal to the threshold (50.0E9). - Timestamp: Tuesday 17 May, 2011 09:07:07 UTC Threshold: - The alarm is in the ALARM state when the metric is LessThanOrEqualToThreshold 3.0E9 for 300 seconds. Monitored Metric: - MetricNamespace: AWS/RDS - MetricName: FreeStorageSpace - Dimensions: - Period: 300 seconds - Statistic: Average - Unit: not specified State Change Actions: - OK: - ALARM: [arn:aws:sns:ap-southeast-1:**********:alarm01] - INSUFFICIENT_DATA: -- If you wish to stop receiving notifications from this topic, please click or visit the link below to unsubscribe: Please do not reply directly to this e-mail. If you have any questions or comments regarding this email, please contact us at sns-question@amazon.com
閾値を自由に設定できるので、クリティカルな状況になる前にメールで通知する事が可能です。
同様の手順でRDSの他の情報も監視する事が出来ます。 もっと本格的な方法もあるかと思いますが、この方法なら今スグにでも実施する事が出来ますね。
RDSの監視をしていない方、監視システムの構築に時間がかかりそうな場合は試してみてはいかがでしょうか?