将指标数据推送到 Cloudwatch 以进行自定义自动缩放

问题描述 投票:0回答:1

我们希望根据 SQS 大小自动缩放。

我能够点击以下链接并在自动扩展组中添加自定义自动扩展策略。

https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-target-tracking-metric-math.html

{
    "CustomizedMetricSpecification": {
        "Metrics": [
            {
                "Label": "Get the queue size (the number of messages waiting to be processed)",
                "Id": "m1",
                "MetricStat": {
                    "Metric": {
                        "MetricName": "ApproximateNumberOfMessagesVisible",
                        "Namespace": "AWS/SQS",
                        "Dimensions": [
                            {
                                "Name": "QueueName",
                                "Value": "my-queue"
                            }
                        ]
                    },
                    "Stat": "Sum"
                },
                "ReturnData": false
            },
            {
                "Label": "Get the group size (the number of InService instances)",
                "Id": "m2",
                "MetricStat": {
                    "Metric": {
                        "MetricName": "GroupInServiceInstances",
                        "Namespace": "AWS/AutoScaling",
                        "Dimensions": [
                            {
                                "Name": "AutoScalingGroupName",
                                "Value": "my-asg"
                            }
                        ]
                    },
                    "Stat": "Average"
                },
                "ReturnData": false
            },
            {
                "Label": "Calculate the backlog per instance",
                "Id": "e1",
                "Expression": "m1 / m2",
                "ReturnData": true
            }
        ]
    },
    "TargetValue": 100
}

执行此代码片段后,我看到两个警报,一个用于缩小规模,另一个用于缩小规模。

问题:上述步骤是否也会将指标数据发布到Cloudwatch?因为我没有看到指标数据填充,这意味着没有发生缩放。

amazon-web-services amazon-ec2 amazon-cloudwatch aws-auto-scaling
1个回答
0
投票

您不需要将任何 SQS 指标发送到 CloudWatch,它们默认由 SQS 发送。您可以在 CloudWatch 中找到

ApproximateNumberOfMessagesVisible
指标,您只需向
my-queue
发送消息并稍等一下(实际上,可能需要几分钟)。

© www.soinside.com 2019 - 2024. All rights reserved.