Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Incorrect configuration after deploying aws_cloudwatch_metric_alarm for anomaly detectors #33515

Open
amitravindrapatil opened this issue Sep 19, 2023 · 2 comments
Labels
bug Addresses a defect in current functionality. service/cloudwatch Issues and PRs that pertain to the cloudwatch service.

Comments

@amitravindrapatil
Copy link

Terraform Core Version

1.4.2

AWS Provider Version

5.11.0

Affected Resource(s)

aws_cloudwatch_metric_alarm

Expected Behavior

After provisioning the metric based on Anomaly Detector , One should be able to edit / delete the model clicking graphed metrics -> anomaly detection band
as shown below
image

Also when similar metric is provisioned using AWS CLI or Cloud formation there is a relationship between Anomaly Detector and Base metric which is not visible for the one provisioned using Terraform. See image below for same metric provisioned from AWS CLI or Cloudformation
image

Actual Behavior

As shown in image below the visual relationship between Anomaly Detector and Base Metric (on which Anomaly detector is based) is missing . Also there is no way one can Edit or Delete the model due to this
image

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_cloudwatch_metric_alarm" "error_rate_dynamic" {
  alarm_name                = "error_rate_dynamic-E3BL0CXXCGASEJ"
  comparison_operator       = "GreaterThanUpperThreshold"
  evaluation_periods        = 5
  threshold_metric_id       = "e1"    
  insufficient_data_actions = []

  metric_query {
    id          = "e1"
    expression  = "ANOMALY_DETECTION_BAND(m1,2)"
    label       = "TotalErrorRate (Expected)"
    return_data = "true"
  }

  metric_query {
    id          = "m1"
    return_data = "true"
    metric {
      metric_name = "TotalErrorRate"
      namespace   = "AWS/CloudFront"
      period      = 60
      stat        = "Average"
      unit        = "Percent"

      dimensions = {
         Region         = "Global"
        DistributionId = "E3BL0CXXCGASEJ"
      }
    }
  } 
}

Steps to Reproduce

  1. Provision cloudwatch metric alarm using the config below in us-east-1 region (due to cloudfront)
resource "aws_cloudwatch_metric_alarm" "error_rate_dynamic" {
  alarm_name                = "error_rate_dynamic-E3BL0CXXCGASEJ"
  comparison_operator       = "GreaterThanUpperThreshold"
  evaluation_periods        = 5
  threshold_metric_id       = "e1"    
  insufficient_data_actions = []

  metric_query {
    id          = "e1"
    expression  = "ANOMALY_DETECTION_BAND(m1,2)"
    label       = "TotalErrorRate (Expected)"
    return_data = "true"
  }

  metric_query {
    id          = "m1"
    return_data = "true"
    metric {
      metric_name = "TotalErrorRate"
      namespace   = "AWS/CloudFront"
      period      = 60
      stat        = "Average"
      unit        = "Percent"

      dimensions = {
         Region         = "Global"
        DistributionId = "E3BL0CXXCGASEJ"
      }
    }
  } 
}
  1. Once provisioned go to cloudwatch metrics in us-east-1 region and click on above metric
  2. Go to graphed metrics , you should see 2 metrics added there 1. TotalErrorRate 2. TotalErrorRate (expected)
  3. Click on Anomaly Detection Band in details column in the grid below and you will see that the Edit / Delete Model is not available

Debug Output

No response

Panic Output

No response

Important Factoids

Please note that changing the order of e1 and m1 in above example does not register as a config change.
If I provision similar metric using CloudFormation or AWS CLI (putMetricAlarm) it works OK

References

No response

Would you like to implement a fix?

None

@amitravindrapatil amitravindrapatil added the bug Addresses a defect in current functionality. label Sep 19, 2023
@github-actions github-actions bot added the service/cloudwatch Issues and PRs that pertain to the cloudwatch service. label Sep 19, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 19, 2023
@kim0
Copy link

kim0 commented Sep 26, 2023

FYI, I did hit this bug today with the below versions

Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v4.67.0

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/cloudwatch Issues and PRs that pertain to the cloudwatch service.
Projects
None yet
Development

No branches or pull requests

3 participants