Navigation

Create One Alert Configuration

Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

Resource

Base URL: https://cloud.mongodb.com/api/atlas/v1.0

POST /groups/{PROJECT-ID}/alertConfigs

Request Path Parameters

Parameter Type Necessity Description
PROJECT-ID string Required Unique identifier for the Project.

Request Query Parameters

This endpoint may use any of the HTTP request query parameters available to all Atlas API resources. These are all optional.

Name Type Necessity Description Default
pageNum integer Optional Page number (1-based). 1
itemsPerPage integer Optional Maximum number of items to return, up to a maximum of 100. 100
pretty boolean Optional Indicates whether the response body should be in a prettyprint format. false
envelope boolean Optional

Indicates whether or not to wrap the response in an envelope.

Some API clients cannot access the HTTP response headers or status code. To remediate this, set envelope=true in the query.

For endpoints that return a list of results, the results object is an envelope. Atlas adds the status field to the response body.

false

Request Body Parameters

Alert configurations depend why you want Atlas to raise an alert. Alerts can be triggered if either:

  • a particular condition is met or
  • a particular metric exceeded a particular value.

To simplify the differences between condition and metrics, click one of the following tabs:

Name Type Necessity Description
enabled boolean Optional Flag that indicates if this alert configuration is enabled or disabled.
eventTypeName string Required

Type of event that triggers an alert.

Alert Target Condition
Billing
CREDIT_CARD_ABOUT_TO_EXPIRE
Credit card is about to expire
PENDING_INVOICE_OVER_THRESHOLD
Monthly pending invoice ($) total is…
DAILY_BILL_OVER_THRESHOLD
Daily amount billed ($) is…
Encryption Key
AWS_ENCRYPTION_KEY_NEEDS_ROTATION
AWS encryption key elapsed time since last rotation is…
AZURE_ENCRYPTION_KEY_NEEDS_ROTATION
Azure encryption key elapsed time since last rotation is…
GCP_ENCRYPTION_KEY_NEEDS_ROTATION
GCP encryption key elapsed time since last rotation is…
Host
HOST_DOWN
Host is down
OUTSIDE_METRIC_THRESHOLD
Click the Metrics tab beneath Request Body Parameters.
Project
USERS_WITHOUT_MULTIFACTOR_AUTH
Users do not have two-factor authentication enabled
Replica Set
PRIMARY_ELECTED
Replica set elected a new primary
NO_PRIMARY
Replica set has no primary
TOO_MANY_ELECTIONS
Number of election events is…
REPLICATION_OPLOG_WINDOW_RUNNING_OUT
Replication Oplog Window is…
Sharded Cluster
CLUSTER_MONGOS_IS_MISSING
Cluster is missing an active mongos
User
USER_ROLES_CHANGED_AUDIT
User had their role changed
JOINED_GROUP
User joined the project
REMOVED_FROM_GROUP
User left the project
USER_ROLES_CHANGED_AUDIT
User had their role changed
X.509
NDS_X509_USER_AUTHENTICATION_MANAGED_USER_CERTS_EXPIRATION_CHECK
X.509 User Authentication, Client Certificates Expiration Alert when days to expiration is…
NDS_X509_USER_AUTHENTICATION_CUSTOMER_CA_EXPIRATION_CHECK
X.509 User Authentication, Self-Managed CA Expiration Alert when days to expiration is…
Name Type Necessity Description
enabled boolean Optional Flag that indicates if this alert configuration is enabled or disabled.
eventTypeName string Required Type of event that triggers an alert. Set this value to OUTSIDE_METRIC_THRESHOLD. You must also set one or more host metrics in the metricThreshold array.
matchers array of objects Required

Rules to apply when matching an object against this alert configuration. Only entities that match all these rules are checked for an alert condition.

Atlas limits filtering alerts using matchers when the eventTypeName specifies an event for the following:

  • a host,
  • a replica set, or
  • a sharded cluster.

To add one or more matchers, see Filter Results.

notifications array of objects Required

One or more targets for Atlas to send notifications when an alert condition is detected. You can configure any number of notifications for each alert condition.

To add one or more notifications, see Set Notifications.

threshold object Conditional

Threshold that triggers an alert. Don’t include if "eventTypeName" : "OUTSIDE_METRIC_THRESHOLD".

To add one threshold, see Trigger Alerts.

metricThreshold object Conditional

Threshold for the metric that, when exceeded, triggers an alert.

To add one metricThreshold, see Trigger Alerts.

Trigger Alerts

threshold
.operator
string Conditional

Operator to apply when checking the current condition against the threshold value. Atlas accepts the following values:

  • GREATER_THAN
  • LESS_THAN
threshold
.threshold
integer Conditional Value of the threshold outside of which triggers an alert.
metricThreshold
.metricName
string Conditional

Name of the metric to check.

See Host Metrics for the available metrics.

metricThreshold
.operator
string Conditional

Operator to apply when checking the current metric value against the threshold value. Atlas accepts the following values:

  • GREATER_THAN
  • LESS_THAN
metricThreshold
.threshold
integer Conditional Value of metricThreshold.metricName outside of which an alert will be triggered.
metricThreshold
.units
string Conditional

Units for the value of metricThreshold.threshold. Depends on the type of metric.

Example

A metric that measures memory consumption would have a byte measurement, while a metric that measures time would have a time unit.

Accepted values for durations are:

  • MILLISECONDS
  • SECONDS
  • MINUTES
  • HOURS
  • DAYS

Accepted values for storage or memory are:

  • BITS
  • KILOBITS
  • MEGABITS
  • GIGABITS
  • BYTES
  • KILOBYTES
  • MEGABYTES
  • GIGABYTES
  • TERABYTES
  • PETABYTES
metricThreshold
.mode
string Conditional This must be set to AVERAGE. Atlas computes the current metric value as an average.

Filter Results

matchers
.fieldName
string Required

Name of the field in the target object that you wanted this configuration to match. Atlas accepts the following values:

Host Replica set Sharded cluster
TYPE_NAME
HOSTNAME
PORT
HOSTNAME_AND_PORT
REPLICA_SET_NAME
REPLICA_SET_NAME
SHARD_NAME
CLUSTER_NAME
CLUSTER_NAME
SHARD_NAME
matchers
.operator
string Optional

Operator to test the field’s value. Atlas accepts the following values:

  • EQUALS
  • NOT_EQUALS
  • CONTAINS
  • NOT_CONTAINS
  • STARTS_WITH
  • ENDS_WITH
  • REGEX
matchers
.value
string Optional

Value against which the specified operator compares.

If "matchers.fieldName" : "TYPE_NAME", you can match on the following values:

  • PRIMARY
  • SECONDARY
  • STANDALONE
  • CONFIG
  • MONGOS

Set Notifications

notifications
.apiToken
string Conditional

Slack API token.

If the token later becomes invalid, Atlas sends an email to the Project Owner and eventually removes the token.

Set this value if "notifications.typeName" : "SLACK".

notifications
.channelName
string Conditional

Slack channel name.

Set this value if "notifications.typeName" : "SLACK".

notifications
.datadogApiKey
string Conditional

Datadog API Key. Found in the Datadog dashboard.

Set this value if "notifications.typeName" : "DATADOG".

notifications
.datadogRegion
string Conditional

Region that indicates which API URL to use. Atlas accepts the following values:

  • US
  • EU

The default Datadog region is US.

Set this value if "notifications.typeName" : "DATADOG".

notifications
.delayMin
integer Conditional Number of minutes to wait after an alert condition is detected before sending out the first notification.
notifications
.emailAddress
string Conditional

Email address to which alert notifications are sent.

Set this value if "notifications.typeName" : "EMAIL".

You don’t need to set this value to send emails to specific users, users with specific project roles, users with specific organization roles, or teams. Use the notifications.emailEnabled parameter for that purpose.

notifications
.emailEnabled
boolean Conditional

Flag indicating if email notifications should be sent to this user’s email address.

Set this value if:

  • "notifications.typeName" : "GROUP"
  • "notifications.typeName" : "ORG"
  • "notifications.typeName" : "USER"
notifications
.flowdockApiToken
string Conditional

Flowdock personal API token.

If the token later becomes invalid, Atlas sends an email to the Project Owner and eventually removes the token.

Set this value if "notifications.typeName" : "FLOWDOCK".

notifications
.flowName
string Conditional

Flowdock flow name in lower-case letters. The flow name appears after the organization name in the URL string:

www.flowdock.com/app/<organization-name>/<flow-name>.

Set this value if "notifications.typeName" : "FLOWDOCK".

notifications
.intervalMin
integer Required Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved. The minimum value is 5.
notifications
.mobileNumber
string Conditional

Mobile number to which alert notifications are sent.

Set this value if "notifications.typeName" : "SMS".

You don’t need to set this value to send emails to specific users, users with specific project roles, users with specific organization roles, or teams. Use the notifications.smsEnabled parameter for that purpose.

notifications
.opsGenieApiKey
string Conditional

Opsgenie API Key.

If the key later becomes invalid, Atlas sends an email to the Project Owner and eventually removes the key.

Set this value if "notifications.typeName" : "OPS_GENIE".

notifications
.opsGenieRegion
string Conditional

Region that indicates which API URL to use. Atlas accepts the following values:

  • US
  • EU

The default Opsgenie region is US.

Set this value if "notifications.typeName" : "OPS_GENIE".

notifications
.orgName
string Conditional

Flowdock organization name in lower-case letters. This is the name that appears after www.flowdock.com/app/ in the URL string.

Set this value if "notifications.typeName" : "FLOWDOCK".

notifications
.roles
array of strings Conditional

One or more roles that receive the configured alert. Atlas accepts the following values:

Project roles Organization roles
  • GROUP_CHARTS_ADMIN
  • GROUP_CLUSTER_MANAGER
  • GROUP_DATA_ACCESS_ADMIN
  • GROUP_DATA_ACCESS_READ_ONLY
  • GROUP_DATA_ACCESS_READ_WRITE
  • GROUP_OWNER
  • GROUP_READ_ONLY
  • ORG_OWNER
  • ORG_MEMBER
  • ORG_GROUP_CREATOR
  • ORG_BILLING_ADMIN
  • ORG_READ_ONLY

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.

Set this value if:

  • "notifications.typeName" : "GROUP"
  • "notifications.typeName" : "ORG"
notifications
.serviceKey
string Conditional

PagerDuty service key.

If the key later becomes invalid, Atlas sends an email to the Project Owner and eventually removes the key.

Set this value if "notifications.typeName" : "PAGER_DUTY".

notifications
.smsEnabled
boolean Conditional

Flag indicating if text message notifications should be sent to this user’s mobile phone.

Set this value if:

  • "notifications.typeName" : "GROUP"
  • "notifications.typeName" : "ORG"
  • "notifications.typeName" : "USER"
notifications
.teamId
string Conditional

Unique identifier of a team.

Set this value if "notifications.typeName" : "TEAM".

notifications
.typeName
string Required

Type of alert notification. Atlas accepts the following values:

  • EMAIL
  • SMS
  • PAGER_DUTY
  • SLACK
  • FLOWDOCK
  • DATADOG
  • OPS_GENIE
  • VICTOR_OPS
  • WEBHOOK
  • USER
  • TEAM
  • GROUP (Project)
  • ORG
notifications
.username
string Conditional

Name of the Atlas user to which to send notifications. This user must belong in the project that owns the alert configuration.

Set this value if "notifications.typeName" : "USER".

notifications
.victorOpsApiKey
string Conditional

VictorOps API key.

If the key later becomes invalid, Atlas sends an email to the Project Owner and eventually removes the key.

Set this value if "notifications.typeName" : "VICTOR_OPS".

notifications
.victorOpsRoutingKey
string Conditional

VictorOps routing key.

If the key later becomes invalid, Atlas sends an email to the Project Owner and eventually removes the key.

Set this value if "notifications.typeName" : "VICTOR_OPS".

Response Elements

The response includes the alert configuration details:

Note

Alert configurations vary. An alert configuration may only include a subset of these elements.

Name Type Description
created string Timestamp in ISO 8601 date and time format in UTC when this alert configuration was created.
enabled boolean Flag indicating this alert configuration enabled.
eventTypeName string Type of event that triggers an alert.
groupId string Unique identifier of the Project that owns this alert configuration.
id string Unique identifier of the alert configuration.
matchers array of objects Rules to apply when matching an object against this alert configuration.
matchers
.fieldName
string Name of the field in the target object that you wanted this configuration to match.
matchers
.operator
string Operator to test the field’s value.
matchers
.value
string Value to test with the specified operator.
metricThreshold object Threshold that triggers an alert. Returned if "eventTypeName" : "OUTSIDE_METRIC_THRESHOLD".
metricThreshold
.metricName
string Name of the metric to check. Supports the same values as the metricName field of the alerts resource.
metricThreshold
.mode
string Average value of this metric.
metricThreshold
.operator
string Operator to apply when checking the current metric value against the threshold value.
metricThreshold
.threshold
number Value that, when exceeded, triggers an alert.
metricThreshold
.units
string Units for the threshold value.
notifications array of objects One or more targets for Atlas to send notifications when an alert condition is detected.
notifications
.apiToken
string Slack API token token. Returned if "notifications.typeName" : "SLACK".
notifications
.channelName
string Slack channel name. Returned if "notifications.typeName" : "SLACK".
notifications
.datadogApiKey
string DataDog API Key. Returned if "notifications.typeName" : "DATADOG".
notifications
.datadogRegion
string Region that indicates which API URL to use.
notifications
.delayMin
number Number of minutes to wait after an alert condition is detected before sending out the first notification.
notifications
.emailAddress
string Email address to which to send notification. Returned if "notifications.typeName" : "EMAIL".
notifications
.emailEnabled
boolean Flag indicating email notifications must be sent. Returned if "notifications.typeName" : "ORG", GROUP, or USER.
notifications
.flowdockApiToken
string Flowdock personal API token. Returned if "notifications.typeName" : "FLOWDOCK".
notifications
.flowName
string Name of the Flowdock flow. Returned if "notifications.typeName" : "FLOWDOCK".
notifications
.intervalMin
number Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved.
notifications
.mobileNumber
string Mobile number to which alert notifications are sent. Set this value if "notifications.typeName" : "SMS".
notifications
.opsGenieApiKey
string Opsgenie API Key. Set this value if "notifications.typeName" : "OPS_GENIE".
notifications
.opsGenieRegion
string Region that indicates which API URL to use. Set this value if "notifications.typeName" : "OPS_GENIE".
notifications
.orgName
string Name of the Flowdock organization. Returned if "notifications.typeName" : "FLOWDOCK".
notifications
.roles
array of strings Atlas role in current Project or Organization. Returned if "notifications.typeName" : "ORG" or GROUP.
notifications
.serviceKey
string PagerDuty service key. Returned if "notifications.typeName" : "PAGER_DUTY".
notifications
.smsEnabled
boolean Flag indicating text notifications must be sent. Returned if "notifications.typeName" : "ORG", GROUP, or USER.
notifications
.teamId
string Unique identifier of a team.
notifications
.typeName
string Type of alert notification.
notifications
.username
string Name of an Atlas user to which to send notifications. Returned if "notifications.typeName" : "USER".
threshold object Threshold that triggers an alert. Returned if eventTypeName is any value other than OUTSIDE_METRIC_THRESHOLD.
threshold
.operator
string Operator to apply when checking the current metric value against the threshold value.
threshold
.threshold
number Threshold value outside of which an alert is triggered.
typeName string This field is deprecated and is ignored.
updated string Timestamp in ISO 8601 date and time format in UTC when this alert configuration was last updated.

Example Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
     --request POST "https://cloud.mongodb.com/api/atlas/v1.0/groups/{PROJECT-ID}/alertConfigs" \
     --header "Content-Type: application/json" \
     --data '
       {
         "eventTypeName" : "REPLICATION_OPLOG_WINDOW_RUNNING_OUT",
         "enabled" : true,
         "notifications" : [ {
           "delayMin" : 0,
           "emailEnabled" : true,
           "intervalMin" : 60,
           "roles" : [ "GROUP_OWNER" ],
           "smsEnabled" : false,
           "typeName" : "GROUP"
         } ],
         "threshold" : {
           "operator" : "LESS_THAN",
           "threshold" : 1
         },
         "typeName" : "REPLICA_SET"
       }'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
     --request POST "https://cloud.mongodb.com/api/atlas/v1.0/groups/{PROJECT-ID}/alertConfigs" \
     --header "Content-Type: application/json" \
     --data '
       {
         "eventTypeName" : "OUTSIDE_METRIC_THRESHOLD",
         "enabled" : true,
         "metricThreshold" : {
           "metricName" : "DISK_PARTITION_SPACE_USED_DATA",
           "mode" : "AVERAGE",
           "operator" : "GREATER_THAN",
           "threshold" : 90.0,
           "units" : "RAW"
         },
         "notifications" : [ {
           "delayMin" : 0,
           "emailEnabled" : true,
           "intervalMin" : 60,
           "roles" : [ "GROUP_OWNER" ],
           "smsEnabled" : false,
           "typeName" : "GROUP"
         } ],
         "typeName" : "HOST_METRIC"
       }'

Example Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  "created":"2020-02-26T01:14:40Z",
  "enabled":true,
  "eventTypeName":"REPLICATION_OPLOG_WINDOW_RUNNING_OUT",
  "groupId":"{PROJECT-ID}",
  "id":"{ALERT-CONFIG-ID}",
  "links":[{
    "href":"https://cloud.mongodb.com/api/public/v1.0/groups/{PROJECT-ID}/alertConfigs/{ALERT-CONFIG-ID}",
    "rel":"self"
  },
  {
    "href":"https://cloud.mongodb.com/api/public/v1.0/groups/{PROJECT-ID}/alertConfigs/{ALERT-CONFIG-ID}/alerts",
    "rel":"http://mms.mongodb.com/alerts"
  }],
  "matchers":[],
  "notifications":[{
    "delayMin":0,
    "emailEnabled":true,
    "intervalMin":60,
    "roles":["GROUP_OWNER"],
    "smsEnabled":false,
    "typeName":"GROUP"
  }],
  "threshold":{
    "operator":"LESS_THAN",
    "threshold":1
  },
  "typeName":"REPLICA_SET",
  "updated":"2020-02-26T01:14:40Z"
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "created" : "2016-06-17T14:51:06Z",
  "enabled" : true,
  "eventTypeName" : "OUTSIDE_METRIC_THRESHOLD",
  "groupId" : "{PROJECT-ID}",
  "id" : "{ALERT-CONFIG-ID}",
  "links" : [ {
    "href" : "https://cloud.mongodb.com/api/public/v1.0/groups/{PROJECT-ID}/alertConfigs/{ALERT-CONFIG-ID}",
    "rel" : "self"
  } ],
  "matchers" : [ ],
  "metricThreshold" : {
    "metricName" : "DISK_PARTITION_SPACE_USED_DATA",
    "mode" : "AVERAGE",
    "operator" : "GREATER_THAN",
    "threshold" : 90.0,
    "units" : "RAW"
  },
  "notifications" : [ {
    "delayMin" : 0,
    "emailEnabled" : true,
    "intervalMin" : 60,
    "roles" : [ "GROUP_OWNER" ],
    "smsEnabled" : false,
    "typeName" : "GROUP"
  } ],
  "typeName" : "HOST_METRIC",
  "updated" : "2016-06-17T14:51:06Z"
}