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

Can't create a alert for Replication Oplog Window #227

Closed
michelzanini opened this issue May 18, 2020 · 13 comments
Closed

Can't create a alert for Replication Oplog Window #227

michelzanini opened this issue May 18, 2020 · 13 comments
Labels
improvement Not a feature but not a bug per se

Comments

@michelzanini
Copy link

michelzanini commented May 18, 2020

Hi,

I can't create a alert for Replication Oplog Window is below 1 hours using Terraform.

This is what I have:

resource "mongodbatlas_alert_configuration" "pager_duty_alert_replication_window" {
  project_id = mongodbatlas_project.project.id
  event_type = "REPLICATION_OPLOG_WINDOW_RUNNING_OUT"
  enabled    = true

  notification {
    type_name    = "PAGER_DUTY"
    service_key  = var.pager_duty_service_key
    delay_min    = 0
    interval_min = local.pager_duty_interval_min
  }
}

But this won't work as this alert needs a threshold. See error:

400 (request "Bad Request") A threshold must be specified for the specified event type.

This threshold has a different JSON format than when using OUTSIDE_METRIC_THRESHOLD. For OUTSIDE_METRIC_THRESHOLD the JSON looks like this:

"metricThreshold": {
   "metricName": "CONNECTIONS_PERCENT",
   "mode": "AVERAGE",
   "operator": "GREATER_THAN",
   "threshold": 80.0,
   "units": "RAW"
},

But for this metric, REPLICATION_OPLOG_WINDOW_RUNNING_OUT, it looks like this:

"threshold": {
   "operator": "LESS_THAN",
   "threshold": 1
}

I tried using in Terraform:

threshold = {
    operator    = "LESS_THAN"
    threshold   = 1
}

But get this error:

Error: Unsupported argument
An argument named "threshold" is not expected here.

And:

metric_threshold = {
    operator    = "LESS_THAN"
    threshold   = 1
    units       = "RAW"
    mode        = "AVERAGE"
  }

And get:

400 (request "Bad Request") The metric threshold should only be specific for host metric alerts.

Is it possible that this metric is not support on Terraform right now, or how do I create it?

Thanks.

@michelzanini
Copy link
Author

I am using version 0.5.1 of the provider, Terraform version 0.12.16

@themantissa
Copy link
Collaborator

@michelzanini we'll take a look but have you reached out to Atlas support? Issues in this repo is for bugs per the README. If you can narrow down the issue with support first it helps a great deal, especially as alerts are some of the most complicated to track down due to the variations available. Also note Atlas API documentation for Alerts was updated recently so there may be some things in the Atlas API we were not able to account for and will have to adjust to match: https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/

@michelzanini
Copy link
Author

I can create the alert via API with a POST:

{
    "enabled": true,
    "eventTypeName": "REPLICATION_OPLOG_WINDOW_RUNNING_OUT",
    "matchers": [],
    "notifications": [
        {
            "delayMin": 0,
            "intervalMin": 60,
            "typeName": "PAGER_DUTY",
            "serviceKey": "2f57fda20b70462bbf8001cfa7a1835a"
        }
    ],
    "threshold": {
        "operator": "LESS_THAN",
        "threshold": 1
    }
}

From Terraform I can't define the threshold block. I think this is missing...

Not sure why would I create a Atlas support ticket for this, but if you still want me to create I can. Please let me know. Thanks.

@themantissa
Copy link
Collaborator

@michelzanini If you were able to set it via API directly but not via Terraform then no, you do not need a support ticket. The reason I mention support is they have the access and staffing to help (much more quickly and thoroughly) and narrow down potential bugs for the developers to address. In this case it seems you have done this on your own, thank you.

I'm assuming this is one that was left off due to the documentation being out of date. Now that the doc is caught up we'll need to improve the provider to match the Atlas reality. We'll update here when addressed.

@michelzanini
Copy link
Author

michelzanini commented May 19, 2020

@themantissa - Actually the documentation seems still not updated as I don't see threshold block in there. Only metricThreshold , which is supported by Terraform.
The reason why I knew how to create it is because I analysed the JSON that returns when doing a GET call.

Resuming - the docs are not up-to-date and so is not Terraform.

Maybe for that a support ticket is needed? Not sure...

Thanks.

@themantissa
Copy link
Collaborator

@michelzanini indeed - I think you are correct. You've done quite a bit of work already. I'll get this sorted out from here on both sides. Thank you!

@themantissa
Copy link
Collaborator

@michelzanini apologies for the length of time to resolution here but wanted to assure you and anyone else that we are working on this and will post updates as we have them.

@themantissa
Copy link
Collaborator

End of week update: believe we've identified what we need to correct this in the provider. Should have what we need early/mid July and then will be able to determine when we can ensure the provider supports this correctly.

@themantissa themantissa added the improvement Not a feature but not a bug per se label Aug 5, 2020
@jtmdb
Copy link

jtmdb commented Aug 17, 2020

Hi @themantissa
I'm using mongodbatlas provider version 0.6.3 and terraform version 0.13 and encountered the same errors when attempting to set event_type = "REPLICATION_OPLOG_WINDOW_RUNNING_OUT".

I have tried with:
"threshold": { "operator": "LESS_THAN", "threshold": 1 }

as well as:
metric_threshold = { operator = "LESS_THAN" threshold = 1.0 units = "HOURS" }

@themantissa
Copy link
Collaborator

@jtmdb apologizes but we had to get a review and update of how to properly support Atlas alerts in Terraform with the underlying API. We have the information now and the work is on the work board but we have not yet gotten to it. We hope to soon but no firm ETA at this time, estimated currently in September.

@PacoDw
Copy link
Contributor

PacoDw commented Aug 19, 2020

Hello @jtmdb, I created a PR implementing the threshold attribute if you want to check more details or play with the new feature see the PR #298.

Let me know if you have another comment or concern, thanks

@PacoDw PacoDw closed this as completed in 10aee3c Aug 26, 2020
@michelzanini
Copy link
Author

I can confirm the fix works after 0.6.4 release. Thanks!

@themantissa
Copy link
Collaborator

Thank you @michelzanini! Very glad to hear that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Not a feature but not a bug per se
Projects
None yet
Development

No branches or pull requests

4 participants