LoginSignup
1
0

More than 5 years have passed since last update.

ターゲット追跡スケーリングポリシーで定義済メトリクス以外を追加

Last updated at Posted at 2018-12-28

※事前に必要な操作権限を与えておく。試すだけならadministratorのIAMポリシーでOK
※今回はDiskWriteOps(インスタンスストアのwrite iops)をスケーリングポリシーにしている

既存のスケーリングポリシーがあれば消しておく

$ aws autoscaling delete-policy --policy-name handson-as-policy --auto-scaling-group-name handson-as-grp 

config.jsonでスケーリングポリシーの定義を作っておく

$ cat config.json 
{
  "CustomizedMetricSpecification": {
    "MetricName": "DiskWriteOps",
    "Dimensions": [
      {
        "Name": "AutoScalingGroupName",
        "Value": "handson-as-grp"
      }
    ],
    "Namespace": "EC2",
    "Statistic": "Average",
    "Unit": "None"
  },
  "TargetValue": 200,
  "DisableScaleIn": false
}

tmp-diskという名前でスケーリングポリシーを追加
追加先はターゲット追跡スケーリングポリシーで作成されたAutoScalingGroupのhandson-as-grp

以下のようにターゲット追跡スケーリングポリシーなのでスケールアウト/スケールインのアラームも2つ作成されています。ターゲット追跡スケーリングポリシーを消すとアラームも消えます

$ aws autoscaling put-scaling-policy --policy-name tmp-disk --auto-scaling-group-name handson-as-grp --policy-type TargetTrackingScaling --target-tracking-configuration file://config.json
{
    "Alarms": [
        {
            "AlarmName": "TargetTracking-handson-as-grp-AlarmHigh-9b96e6c4-f5e4-4b3a-870d-9f17b2d68d14", 
            "AlarmARN": "arn:aws:cloudwatch:ap-northeast-1:xxxxxxxxxxxx:alarm:TargetTracking-handson-as-grp-AlarmHigh-9b96e6c4-f5e4-4b3a-870d-9f17b2d68d14"
        }, 
        {
            "AlarmName": "TargetTracking-handson-as-grp-AlarmLow-de827d81-bce3-4d46-86ec-03396c639745", 
            "AlarmARN": "arn:aws:cloudwatch:ap-northeast-1:xxxxxxxxxxxx:alarm:TargetTracking-handson-as-grp-AlarmLow-de827d81-bce3-4d46-86ec-03396c639745"
        }
    ], 
    "PolicyARN": "arn:aws:autoscaling:ap-northeast-1:xxxxxxxxxxxx:scalingPolicy:cbfffc44-3c0e-459f-a976-42de82284d87:autoScalingGroupName/handson-as-grp:policyName/tmp-disk"
}

スクリーンショット 0030-12-28 9.57.03.png

スクリーンショット 0030-12-28 9.56.43.png

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