Skip to content

[aws-cloudwatch] Missing ThresholdMetricId #10540

@alextriaca

Description

@alextriaca

When creating Cloudwatch Alarm that makes use of anomaly detection the following error is raised at deploy time:

ComparisonOperators for ranges require ThresholdMetricId to be set (Service: AmazonCloudWatch; Status Code: 400; Error Code: ValidationError; Request ID: xxx; Proxy: null)

Reproduction Steps

aws_cloudwatch.Alarm(
     self,
    "my_alarm",
    evaluation_periods=1,
    metric=sqs_queue.metric_number_of_messages_sent(),
    threshold=2,
    statistic="Average",
    comparison_operator=aws_cloudwatch.ComparisonOperator.LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD,
)

The Alarm construct works great for any of the other ComparisonOperators that do not rely on anomaly detection i.e. GreaterThanThreshold.

Environment

  • CLI Version : 1.62.0
  • Framework Version: 1.64.0
  • Node.js Version: v12.14.1
  • OS : MacOS Catalina
  • Language (Version): Python 3.7

This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchbugThis issue is a bug.effort/mediumMedium work item – several days of effortin-progressThis issue is being actively worked on.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions