Skip to content

mongodbatlas_alert_configuration - metric_threshold.threshold is not being passed when value is zero #311

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

Closed
Jeinhaus opened this issue Sep 10, 2020 · 4 comments
Assignees
Labels

Comments

@Jeinhaus
Copy link

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v0.12.27
+ provider.mongodbatlas v0.6.4

Terraform Configuration File

resource "mongodbatlas_alert_configuration" "restarts_in_last_hour" {
  event_type = "OUTSIDE_METRIC_THRESHOLD"
  project_id = mongodbatlas_cluster.this.project_id

  metric_threshold = {
    metric_name = "RESTARTS_IN_LAST_HOUR"
    operator    = "GREATER_THAN"
    threshold   = 0
    units       = "RAW"
    mode        = "AVERAGE"
  }

  notification {
    type_name     = "GROUP"
    email_enabled = true
    roles         = ["GROUP_OWNER"]
    interval_min  = 60
  }
}

Steps to Reproduce

  1. terraform init
  2. terraform apply

Expected Behavior

terraform apply should run without errors and an alert should be created

Actual Behavior

When running terraform apply it fails with the following message:

Error: error creating Alert Configuration information: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/<redacted>/alertConfigs: 400 (request "Bad Request") The required attribute threshold was not specified.

  on main.tf line 158, in resource "mongodbatlas_alert_configuration" "restarts_in_last_hour":
 158: resource "mongodbatlas_alert_configuration" "restarts_in_last_hour" {


[terragrunt] 2020/09/10 10:34:00 Hit multiple errors:
exit status 1

Additional Context

It is a bit weird, that all other alerts that are configured similarly were applied successfully. So far this has been the only one not working as expected.

@nikhil-mongo
Copy link
Collaborator

@Jeinhaus Thanks for reporting this. As I could see in the debug logs, when threshold = "0" is passed, this parameter is not passing through the API request. However when this is changed to threshold = "1" this is accepted and is passed to the API.
threshold = "0" debug.log
threshold = "1" debug.log

Hope this will help in troubleshooting.

@themantissa themantissa changed the title "mongodbatlas_alert_configuration" for metric "RESTARTS_IN_LAST_HOUR" fails with "The required attribute threshold was not specified" mongodbatlas_alert_configuration - metric_threshold.threshold is not being passed when value is zero Sep 16, 2020
@themantissa
Copy link
Collaborator

@nikhil-mongo thank you for the debug logs and @Jeinhaus for the report. Seems like a bug when its zero. Sadly we don't have a >= as a work around so we'll add this to our queue.

@themantissa
Copy link
Collaborator

Internal ID: INTMDB-118

@themantissa
Copy link
Collaborator

themantissa commented Oct 29, 2020

Fix done and will be included in 0.8.0, closing issue. (updated to be correct version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants