0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AutoScaling+CloudWatch設定で詰まった話

0
Posted at

はじめに

上記の記事でAutoScalingを使用した環境を構築しました。その際に、AutoScalingGroupのインスタンスのメトリクスを収集しようとした際に設定で詰まったので、詰まった点と解決方法を備忘録としてアウトプットします。

やろうとしていたこと

  • AutoScalingGroupのインスタンス数が最大値になったらAlarmが発火し、SNSで配信されるようにしたい

テンプレート(抜粋)

#SNS Topic
  SNSTopicEC2:
    Type: AWS::SNS::Topic
    Properties: 
      DisplayName: "EC2 Monitoring Notifications"
      TopicName: "EC2-MaxInstances-Alarm-Topic"
#SNS Subscription
  SNSSubscriptionEC2:
    Type: AWS::SNS::Subscription
    Properties:
      TopicArn: !Ref SNSTopicEC2
      Protocol: "email"
      Endpoint: !Ref MyEmailAddress
#Cloud Watch Alarm
  EC2MaxInstancesAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: "EC2-MaxInstances-Alarm"
      AlarmDescription: "Alarm when ASG reaches max instance count"
      Namespace: AWS/AutoScaling
      Dimensions:
        - Name: AutoScalingGroupName
          Value: !Ref AutoScalingGroup     
      MetricName: "GroupInServiceInstances"
      Statistic: "Average"
      Period: 60
      Threshold: 2
      ComparisonOperator: "GreaterThanOrEqualToThreshold"
      EvaluationPeriods: 1
      ActionsEnabled: true
      AlarmActions:
        - !Ref SNSTopicEC2

問題発生

  • ストレステストを実施したところ、CloudWatchがデータ不足のままになっており、Alarmが発火しない

原因

MetricsCollection
Enables the monitoring of group metrics of an Auto Scaling group. By default, these metrics are disabled.
Required: No
Type: Array of MetricsCollection
Update requires: No interruption

  • MetricsCollectionがデフォルトでは無効となっており、メトリクスデータが収集されていなかった
  • EC2インスタンスのCPU使用率のメトリクスをCloudWatchで監視した際は、特に設定をしなくてもメトリクスが収集できていたので、今回も同じだと早合点したorz

教訓

  • 都度、公式ドキュメントをきちんと読むことの重要性を痛感しました
  • 特に新しいことをする時は、まず公式ドキュメントを読む

余談

名前空間によって収集できるメトリクスは決まっている

Namespace 主なメトリック
AWS/EC2 CPUUtilization、DiskReadOps、NetworkIn
AWS/AutoScaling GroupInServiceInstances、GroupDesiredCapacity
AWS/RDS CPUUtilization、DatabaseConnections

最初はここを理解しておらず、AWS/AutoScalingでCPUUtilizationを収集しようとしていました。それは失敗するわな。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?