layout | page_title | sidebar_current | description |
---|---|---|---|
mongodbatlas |
MongoDB Atlas: alert_configuration |
docs-mongodbatlas-resource-alert-configuration |
Provides an Alert Configuration resource. |
mongodbatlas_alert_configuration
provides an Alert Configuration resource to define the conditions that trigger an alert and the methods of notification within a MongoDB Atlas project.
-> NOTE: Groups and projects are synonymous terms. You may find groupId
in the official documentation.
resource "mongodbatlas_alert_configuration" "test" {
project_id = "<PROJECT-ID>"
event_type = "OUTSIDE_METRIC_THRESHOLD"
enabled = true
notification {
type_name = "GROUP"
interval_min = 5
delay_min = 0
sms_enabled = false
email_enabled = true
roles = ["GROUP_CHARTS_ADMIN", "GROUP_CLUSTER_MANAGER"]
}
matcher {
field_name = "HOSTNAME_AND_PORT"
operator = "EQUALS"
value = "SECONDARY"
}
metric_threshold_config {
metric_name = "ASSERT_REGULAR"
operator = "LESS_THAN"
threshold = 99.0
units = "RAW"
mode = "AVERAGE"
}
}
-> NOTE: In order to allow for a fast pace of change to alert variables some validations have been removed from this resource in order to unblock alert creation. Impacted areas have links to the MongoDB Atlas API documentation so always check it for the most current information: https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/
resource "mongodbatlas_alert_configuration" "test" {
project_id = "<PROJECT-ID>"
event_type = "REPLICATION_OPLOG_WINDOW_RUNNING_OUT"
enabled = true
notification {
type_name = "GROUP"
interval_min = 5
delay_min = 0
sms_enabled = false
email_enabled = true
roles = ["GROUP_CHARTS_ADMIN", "GROUP_CLUSTER_MANAGER"]
}
matcher {
field_name = "HOSTNAME_AND_PORT"
operator = "EQUALS"
value = "SECONDARY"
}
threshold_config {
operator = "LESS_THAN"
threshold = 1
units = "HOURS"
}
}
resource "mongodbatlas_alert_configuration" "test" {
project_id = "PROJECT ID"
event_type = "OUTSIDE_METRIC_THRESHOLD"
enabled = true
notification {
type_name = "GROUP"
interval_min = 5
delay_min = 0
sms_enabled = false
email_enabled = true
roles = ["GROUP_DATA_ACCESS_READ_ONLY", "GROUP_CLUSTER_MANAGER", "GROUP_DATA_ACCESS_ADMIN"]
}
notification {
type_name = "ORG"
interval_min = 5
delay_min = 0
sms_enabled = true
email_enabled = false
}
matcher {
field_name = "HOSTNAME_AND_PORT"
operator = "EQUALS"
value = "SECONDARY"
}
metric_threshold_config {
metric_name = "ASSERT_REGULAR"
operator = "LESS_THAN"
threshold = 99.0
units = "RAW"
mode = "AVERAGE"
}
}
-
project_id
- (Required) The ID of the project where the alert configuration will create. -
enabled
- It is not required, but If the attribute is omitted, by default will be false, and the configuration would be disabled. You must set true to enable the configuration. -
event_type
- (Required) The type of event that will trigger an alert.-> IMPORTANT: Event Type has many possible values. All current options at available at https://docs.atlas.mongodb.com/reference/api/alert-configurations-create-config/ Details for both conditional and metric based alerts can be found by selecting the tabs on the alert config page and checking the latest eventTypeName options.
-> NOTE: If
event_type
is set to OUTSIDE_METRIC_THRESHOLD, the metricThreshold field must also be set.
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.
Host alerts | Replica set alerts | Sharded cluster alerts |
---|---|---|
TYPE_NAME |
REPLICA_SET_NAME |
CLUSTER_NAME |
HOSTNAME |
SHARD_NAME |
SHARD_NAME |
PORT |
CLUSTER_NAME |
|
HOSTNAME_AND_PORT |
||
REPLICA_SET_NAME |
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. Accepted values are:EQUALS
NOT_EQUALS
CONTAINS
NOT_CONTAINS
STARTS_WITH
ENDS_WITH
REGEX
-
value
- Value to test with the specified operator. Iffield_name
is set to TYPE_NAME, you can match on the following values:PRIMARY
SECONDARY
STANDALONE
CONFIG
MONGOS
The threshold that causes an alert to be triggered. Required if event_type_name
: "OUTSIDE_METRIC_THRESHOLD".
-
metric_name
- Name of the metric to check. The full list of current options is available here -
operator
- Operator to apply when checking the current metric value against the threshold value. Accepted values are:GREATER_THAN
LESS_THAN
-
threshold
- Threshold value outside of which an alert will be triggered. -
units
- The units for the threshold value. Depends on the type of metric. Accepted values are:RAW
BITS
BYTES
KILOBITS
KILOBYTES
MEGABITS
MEGABYTES
GIGABITS
GIGABYTES
TERABYTES
PETABYTES
MILLISECONDS
SECONDS
MINUTES
HOURS
DAYS
-
mode
- This must be set to AVERAGE. Atlas computes the current metric value as an average.
-
operator
- Operator to apply when checking the current metric value against the threshold value. Accepted values are:GREATER_THAN
LESS_THAN
-
threshold
- Threshold value outside of which an alert will be triggered. -
units
- The units for the threshold value. Depends on the type of metric. Accepted values are: -RAW
-BITS
-BYTES
-KILOBITS
-KILOBYTES
-MEGABITS
-MEGABYTES
-GIGABITS
-GIGABYTES
-TERABYTES
-PETABYTES
-MILLISECONDS
-SECONDS
-MINUTES
-HOURS
-DAYS
List of notifications to send when an alert condition is detected.
-
api_token
- Slack API token. Required for the SLACK notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token. -
channel_name
- Slack channel name. Required for the SLACK notifications type. -
datadog_api_key
- Datadog API Key. Found in the Datadog dashboard. Required for the DATADOG notifications type. -
datadog_region
- Region that indicates which API URL to use. Accepted regions are:US
,EU
. The default Datadog region is US. -
delay_min
- Number of minutes to wait after an alert condition is detected before sending out the first notification. -
email_address
- Email address to which alert notifications are sent. Required for the EMAIL notifications type. -
email_enabled
- Flag indicating email notifications should be sent. This flag is only valid iftype_name
is set toORG
,GROUP
, orUSER
. -
flowdock_api_token
- The Flowdock personal API token. Required for theFLOWDOCK
notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token. -
flow_name
- Flowdock flow name in lower-case letters. Required for theFLOWDOCK
notifications type -
interval_min
- Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved. The minimum value is 5. NOTEPAGER_DUTY
,VICTOR_OPS
, andOPS_GENIE
notifications do not return this value. The notification interval must be configured and managed within each external service. -
mobile_number
- Mobile number to which alert notifications are sent. Required for the SMS notifications type. -
ops_genie_api_key
- Opsgenie API Key. Required for theOPS_GENIE
notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the token. -
ops_genie_region
- Region that indicates which API URL to use. Accepted regions are:US
,EU
. The default Opsgenie region is US. -
org_name
- Flowdock organization name in lower-case letters. This is the name that appears after www.flowdock.com/app/ in the URL string. Required for the FLOWDOCK notifications type. -
service_key
- PagerDuty service key. Required for the PAGER_DUTY notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key. -
sms_enabled
- Flag indicating if text message notifications should be sent to this user's mobile phone. This flag is only valid iftype_name
is set toORG
,GROUP
, orUSER
. -
team_id
- Unique identifier of a team. -
type_name
- Type of alert notification. Accepted values are:DATADOG
EMAIL
FLOWDOCK
GROUP
(Project)OPS_GENIE
ORG
PAGER_DUTY
SLACK
SMS
TEAM
USER
VICTOR_OPS
WEBHOOK
-
username
- Name of the Atlas user to which to send notifications. Only a user in the project that owns the alert configuration is allowed here. Required for theUSER
notifications type. -
victor_ops_api_key
- VictorOps API key. Required for theVICTOR_OPS
notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key. -
victor_ops_routing_key
- VictorOps routing key. Optional for theVICTOR_OPS
notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key. -
roles
- Optional. One or more roles that receive the configured alert. If you include this field, Atlas sends alerts only to users assigned the roles you specify in the array. If you omit this field, Atlas sends alerts to users assigned any role. This parameter is only valid iftype_name
is set toORG
,GROUP
, orUSER
. Accepted values are:Project roles Organization roles GROUP_CHARTS_ADMIN
ORG_OWNER
GROUP_CLUSTER_MANAGER
ORG_MEMBER
GROUP_DATA_ACCESS_ADMIN
ORG_GROUP_CREATOR
GROUP_DATA_ACCESS_READ_ONLY
ORG_BILLING_ADMIN
GROUP_DATA_ACCESS_READ_WRITE
ORG_READ_ONLY
GROUP_OWNER
GROUP_READ_ONLY
In addition to all arguments above, the following attributes are exported:
id
- Unique identifier used for terraform for internal manages and can be used to import.alert_configuration_id
- Unique identifier for the alert configuration.group_id
- Unique identifier of the project that owns this alert configuration.created
- Timestamp in ISO 8601 date and time format in UTC when this alert configuration was created.updated
- Timestamp in ISO 8601 date and time format in UTC when this alert configuration was last updated.
Alert Configuration can be imported using the project_id-alert_configuration_id
, e.g.
$ terraform import mongodbatlas_alert_configuration.test 5d0f1f74cf09a29120e123cd-5d0f1f74cf09a29120e1fscg
For more information see: MongoDB Atlas API Reference.