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

fix: INTMDB-1017 - Updated alert configuration schema with required params #1421

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mongodbatlas/fw_resource_mongodbatlas_alert_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ func (r *AlertConfigurationRS) Schema(ctx context.Context, req resource.SchemaRe
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"field_name": schema.StringAttribute{
Optional: true,
Required: true,
},
"operator": schema.StringAttribute{
Optional: true,
Required: true,
},
"value": schema.StringAttribute{
Optional: true,
Required: true,
},
},
},
Expand All @@ -184,7 +184,7 @@ func (r *AlertConfigurationRS) Schema(ctx context.Context, req resource.SchemaRe
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"metric_name": schema.StringAttribute{
Optional: true,
Required: true,
},
"operator": schema.StringAttribute{
Optional: true,
Expand Down Expand Up @@ -330,7 +330,7 @@ func (r *AlertConfigurationRS) Schema(ctx context.Context, req resource.SchemaRe
},
},
"type_name": schema.StringAttribute{
Optional: true,
Required: true,
Validators: []validator.String{
stringvalidator.OneOf("EMAIL", "SMS", pagerDuty, "SLACK",
"DATADOG", opsGenie, victorOps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"os"
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
Expand Down Expand Up @@ -59,8 +58,6 @@ func TestAccConfigRSAlertConfiguration_EmptyMetricThresholdConfig(t *testing.T)
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasAlertConfigurationConfigEmptyMetricThresholdConfig(orgID, projectName, true),
// metric threshold is not created so state is inconsistent with plan
ExpectError: regexp.MustCompile("Error: Provider produced inconsistent result after apply"),
},
},
})
Expand Down Expand Up @@ -847,9 +844,6 @@ resource "mongodbatlas_alert_configuration" "test" {
roles = ["GROUP_OWNER"]
}


metric_threshold_config {}

threshold_config {
operator = "LESS_THAN"
threshold = 72
Expand Down
16 changes: 6 additions & 10 deletions website/docs/r/alert_configuration.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ resource "mongodbatlas_alert_configuration" "test" {
### Matchers
Rules to apply when matching an object against this alert configuration. Only entities that match all these rules are checked for an alert condition. You can filter using the matchers array only when the eventTypeName specifies an event for a host, replica set, or sharded cluster.

* `field_name` - Name of the field in the target object to match on.
* `field_name` - (Required) Name of the field in the target object to match on.

| Host alerts | Replica set alerts | Sharded cluster alerts |
|:---------- |:------------- |:------ |
Expand All @@ -144,13 +144,9 @@ Rules to apply when matching an object against this alert configuration. Only en



All other types of alerts do not support matchers.
All other types of alerts do not support matchers.

* `operator` - If omitted, the configuration is disabled.
* `value` - If omitted, the configuration is disabled.


* `operator` - The operator to test the field’s value.
* `operator` - (Required) The operator to test the field’s value.
Accepted values are:
- `EQUALS`
- `NOT_EQUALS`
Expand All @@ -160,7 +156,7 @@ Rules to apply when matching an object against this alert configuration. Only en
- `ENDS_WITH`
- `REGEX`

* `value` - Value to test with the specified operator. If `field_name` is set to TYPE_NAME, you can match on the following values:
* `value` - (Required) Value to test with the specified operator. If `field_name` is set to TYPE_NAME, you can match on the following values:
- `PRIMARY`
- `SECONDARY`
- `STANDALONE`
Expand All @@ -170,7 +166,7 @@ Rules to apply when matching an object against this alert configuration. Only en
### Metric Threshold Config (`metric_threshold_config`)
The threshold that causes an alert to be triggered. Required if `event_type_name` : `OUTSIDE_METRIC_THRESHOLD` or `OUTSIDE_SERVERLESS_METRIC_THRESHOLD`

* `metric_name` - Name of the metric to check. The full list being quite large, please refer to atlas docs [here for general metrics](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types) and [here for serverless metrics](https://www.mongodb.com/docs/atlas/reference/api/alert-configurations-create-config/#serverless-measurements)
* `metric_name` - (Required) Name of the metric to check. The full list being quite large, please refer to atlas docs [here for general metrics](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types) and [here for serverless metrics](https://www.mongodb.com/docs/atlas/reference/api/alert-configurations-create-config/#serverless-measurements)
* `operator` - Operator to apply when checking the current metric value against the threshold value.
Accepted values are:
- `GREATER_THAN`
Expand Down Expand Up @@ -213,7 +209,7 @@ List of notifications to send when an alert condition is detected.
* `sms_enabled` - Flag indicating if text message notifications should be sent to this user's mobile phone. This flag is only valid if `type_name` is set to `ORG`, `GROUP`, or `USER`.
* `team_id` - Unique identifier of a team.
* `team_name` - Label for the team that receives this notification.
* `type_name` - Type of alert notification.
* `type_name` - (Required) Type of alert notification.
Accepted values are:
- `DATADOG`
- `EMAIL`
Expand Down