question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scaleOnMetric does not allow to change periods/datapoints to alarm

See original GitHub issue

Hi , how to change the defaults alarms created with autoscaling module for scaleOnMetric ? It sets datapoints to 1 and period to 60s. I tried this but it does not work (shows no changes):

scaling = autoscalinggroup.scale_on_metric(
            f'ScaleToNrMessInQueue-{stage}-{app_name}-{version}',
            metric=queue.metric("ApproximateNumberOfMessagesVisible"),
            scaling_steps=[
                autoscaling.ScalingInterval(upper=0, change=0),
                autoscaling.ScalingInterval(lower=0, upper=1, change=1),
                autoscaling.ScalingInterval(lower=2, upper=3, change=2),
                autoscaling.ScalingInterval(lower=3, change=3)
            ],
            adjustment_type=autoscaling.AdjustmentType.EXACT_CAPACITY
        )

scaling.lower_alarm.datapoints_to_alarm = 5
scaling.lower_alarm.evaluation_periods = 5
scaling.lower_alarm.period = core.Duration.minutes(5)

I see one such property hardcoded here https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts#L110

Environment

  • CDK CLI Version: 1.19.0 (build 5597bbe)
  • Module Version: latest/master
  • OS: Windows 7
  • Language: Python

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
NetaNircommented, Mar 10, 2020

@toleabivol,

Wouldn’t you be able to achieve this by setting grace on the health_check property of the autoscalinggroup to allow warm up time? see CloudFormation docs.

You can add it to the autoscalinggroup:

        asg = autoscaling.AutoScalingGroup(
        self,
        "ASG",
        vpc=vpc,
        instance_type=ec2.InstanceType.of(
        ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO,
        ),
        health_check=autoscaling.HealthCheck.ec2(grace=core.Duration.seconds(5)),
        machine_image=ec2.AmazonLinuxImage(generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX_2)
        )

Generally, to override the lower_alarm properties you need to use escape hatches which will allow you to override the defined alarm properties:

cfn_alarm = scaling.lower_alarm.node.default_child
cfn_alarm.evaluation_periods = 5
0reactions
github-actions[bot]commented, Jun 21, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Amazon CloudWatch alarms - AWS Documentation
In the following figure, the alarm threshold for a metric alarm is set to three units. Both Evaluation Period and Datapoints to Alarm...
Read more >
awslabs/aws-cdk - Gitter
Hi , how to change the defaults alarms created with autoscaling module for scaleOnMetric ? It sents datapoints to 1 and period to...
Read more >
@aws-cdk/aws-applicationautoscaling - npm
The AutoScaling construct library will create the required CloudWatch alarms and AutoScaling policies for you. Scaling based on multiple ...
Read more >
CloudWatch — Boto3 Docs 1.26.37 documentation
If ignore , the alarm state does not change during periods with too few data points to be statistically significant. If evaluate or...
Read more >
AWS Cloudwatch Alarm Setup Tutorial | Step by Step - YouTube
AWS Cloudwatch Alarms are an important tool to get notified in case your application starts experiencing issues. This can range from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found