Navigation

Create an 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.

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

Syntax

POST /groups/{GROUP-ID}/alertConfigs

Request Path Parameters

Parameter Required/Optional Description
GROUP-ID Required Project identifier.

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 Description Default
pageNum integer Page number (1-based). 1
itemsPerPage integer Maximum number of items to return, up to a maximum of 100. 100
pretty boolean Display response in a prettyprint format. false
envelope boolean Specifies whether or not to wrap the response in an envelope. false

Request Body Parameters

Note

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

Name Type Description
eventTypeName string

Required. The type of event that will trigger an alert.

Alert type Possible values
Host OUTSIDE_METRIC_THRESHOLD HOST_RESTARTED HOST_UPGRADED HOST_NOW_SECONDARY HOST_NOW_PRIMARY
Replica set NO_PRIMARY TOO_MANY_ELECTIONS
Sharded cluster CLUSTER_MONGOS_IS_MISSING
User JOINED_GROUP REMOVED_FROM_GROUP USER_ROLES_CHANGED_AUDIT
Project USERS_AWAITING_APPROVAL USERS_WITHOUT_MULTI_FACTOR_AUTH GROUP_CREATED
Team JOINED_TEAM REMOVED_FROM_TEAM
Organization INVITED_TO_ORG JOINED_ORG
Billing CREDIT_CARD_ABOUT_TO_EXPIRE CHARGE_SUCCEEDED INVOICE_CLOSED

If this is set to OUTSIDE_METRIC_THRESHOLD, the metricThreshold field must also be set.

enabled boolean If omitted, the configuration is disabled.
matchers object array

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.

matchers.fieldName string

Name of the field in the target object to match on.

  • Host alerts support these fields:
    • TYPE_NAME
    • HOSTNAME
    • PORT
    • HOSTNAME_AND_PORT
    • REPLICA_SET_NAME
  • Replica set alerts support these fields:
    • REPLICA_SET_NAME
    • SHARD_NAME
    • CLUSTER_NAME
  • Sharded cluster alerts support these fields:
    • CLUSTER_NAME
    • SHARD_NAME

All other types of alerts do not support matchers.

matchers.operator string

The operator to test the field’s value. Accepted values are:

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

Value to test with the specified operator.

If matchers.fieldName is set to TYPE_NAME, you can match on the following values:

  • PRIMARY
  • SECONDARY
  • STANDALONE
  • CONFIG
  • MONGOS
metricThreshold object The threshold that causes an alert to be triggered. Populated if "eventTypeName" : "OUTSIDE_METRIC_THRESHOLD".
metricThreshold.metricName string

Name of the metric to check.

See Measurement Values for the available metrics.

metricThreshold.operator string

Operator to apply when checking the current metric value against the threshold value. Accepted values are:

  • GREATER_THAN
  • LESS_THAN
metricThreshold.threshold integer Threshold value outside of which an alert will be triggered.
metricThreshold.units string

The units for the threshold value. 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 are:

  • RAW
  • BITS
  • BYTES
  • KILOBITS
  • KILOBYTES
  • MEGABITS
  • MEGABYTES
  • GIGABITS
  • GIGABYTES
  • TERABYTES
  • PETABYTES
  • MILLISECONDS
  • SECONDS
  • MINUTES
  • HOURS
  • DAYS
metricThreshold.mode string This must be set to AVERAGE. Atlas computes the current metric value as an average.
notifications object array Required. Notifications to send when an alert condition is detected.
notifications.typeName string

Type of alert notification. Accepted values are:

  • ORG
  • GROUP (Project)
  • USER
  • TEAM
  • EMAIL
  • SMS
  • HIPCHAT
  • SLACK
  • FLOWDOCK
  • PAGER_DUTY
  • WEBHOOK
  • VICTOR_OPS
  • OPS_GENIE
notifications.intervalMin integer Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved. The minimum value is 5.
notifications.delayMin integer Number of minutes to wait after an alert condition is detected before sending out the first notification.
notifications.emailEnabled boolean Flag indicating if email notifications should be sent. Populated for ORG, GROUP, and USER notifications types.
notifications.smsEnabled boolean Flag indicating if text message notifications should be sent. Populated for ORG, GROUP, and USER notifications types.
notifications.username string Name of the Atlas user to which to send notifications. Only a user in the project that owns the alert configuration is allowed here. Populated for the USER notifications type.
notifications.teamId string Unique identifier of a team.
notifications.emailAddress string Email address to which alert notifications should be sent. Populated for the EMAIL notifications type.
notifications.mobileNumber string Mobile number to which alert notifications should be sent. Populated for the SMS notifications type.
notifications.notificationToken string HipChat API token. Populated for the HIP_CHAT notifications types. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
notifications.roomName string HipChat room name. Populated for the HIP_CHAT notifications type.
notifications.channelName string Slack channel name. Populated for the SLACK notifications type.
notifications.apiToken string Slack API token or Bot token. Populated for the SLACK notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
notifications.orgName string Flowdock organization name in lower-case letters. This is the name that appears after www.flowdock.com/app/ in the URL string. Populated for the FLOWDOCK notifications type.
notifications.flowName string

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>.

Populated for the FLOWDOCK notifications type.

notifications.flowdockApiToken string The Flowdock personal API token. Populated for the FLOWDOCK notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
notifications.serviceKey string PagerDuty service key. Populated 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.
notifications.victorOpsApiKey string VictorOps API key. Populated for the VICTOR_OPS notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key.
notifications.victorOpsRoutingKey string VictorOps routing key. Populated for the VICTOR_OPS notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key.
notifications.opsGenieApiKey string OpsGenie API Key. Populated for the OPS_GENIE notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.

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
id string Unique identifier.
groupId string Unique identifier of the project that owns this alert configuration.
eventTypeName string

Type of event that will trigger an alert.

Accepted values are:

Alert type Possible values
Host OUTSIDE_METRIC_THRESHOLD HOST_RESTARTED HOST_UPGRADED HOST_NOW_SECONDARY HOST_NOW_PRIMARY
Replica set NO_PRIMARY TOO_MANY_ELECTIONS
Sharded cluster CLUSTER_MONGOS_IS_MISSING
User JOINED_GROUP REMOVED_FROM_GROUP USER_ROLES_CHANGED_AUDIT
Project USERS_AWAITING_APPROVAL USERS_WITHOUT_MULTI_FACTOR_AUTH GROUP_CREATED
Team JOINED_TEAM REMOVED_FROM_TEAM
Organization INVITED_TO_ORG JOINED_ORG
Billing CREDIT_CARD_ABOUT_TO_EXPIRE CHARGE_SUCCEEDED INVOICE_CLOSED
created string Timestamp in ISO 8601 date and time format in UTC when this alert configuration was created.
updated string Timestamp in ISO 8601 date and time format in UTC when this alert configuration was last updated.
enabled boolean

If set to true, the alert configuration is enabled.

If enabled is not specified in a POST command, it defaults to false.

matchers object array

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.

matchers.fieldName string

Name of the field in the target object to match on.

  • Host alerts support these fields:
    • TYPE_NAME
    • HOSTNAME
    • PORT
    • HOSTNAME_AND_PORT
    • REPLICA_SET_NAME
  • Replica set alerts support these fields:
    • REPLICA_SET_NAME
    • SHARD_NAME
    • CLUSTER_NAME
  • Sharded cluster alerts support these fields:
    • CLUSTER_NAME
    • SHARD_NAME

All other types of alerts do not support matchers.

matchers.operator string

The operator to test the field’s value. Accepted values are:

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

Value to test with the specified operator.

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

  • PRIMARY
  • SECONDARY
  • STANDALONE
  • CONFIG
  • MONGOS
metricThreshold object The threshold that causes an alert to be triggered. Populated if "eventTypeName" : "OUTSIDE_METRIC_THRESHOLD".
metricThreshold.metricName string

Name of the metric against which Atlas checks the configured metricThreshold.threshold.

See Measurement Values for the available metrics.

metricThreshold.operator string

Operator to apply when checking the current metric value against the threshold value. Accepted values are:

  • GREATER_THAN
  • LESS_THAN
metricThreshold.threshold integer Threshold value outside of which an alert will be triggered.
metricThreshold.units string

The units for the threshold value. 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 are:

  • RAW
  • BITS
  • BYTES
  • KILOBITS
  • KILOBYTES
  • MEGABITS
  • MEGABYTES
  • GIGABITS
  • GIGABYTES
  • TERABYTES
  • PETABYTES
  • MILLISECONDS
  • SECONDS
  • MINUTES
  • HOURS
  • DAYS
metricThreshold.mode string AVERAGE. Atlas computes the current metric value as an average.
notifications object array Notifications to send when an alert condition is detected.
notifications.typeName string

Type of alert notification. Accepted values are:

  • ORG
  • GROUP (Project)
  • USER
  • TEAM
  • EMAIL
  • SMS
  • HIPCHAT
  • SLACK
  • FLOWDOCK
  • PAGER_DUTY
  • WEBHOOK
  • VICTOR_OPS
  • OPS_GENIE
notifications.intervalMin integer Number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved.
notifications.delayMin integer Number of minutes to wait after an alert condition is detected before sending out the first notification.
notifications.emailEnabled boolean Flag indicating if email notifications should be sent. Populated for ORG, GROUP, and USER notifications types.
notifications.smsEnabled boolean Flag indicating if text message notifications should be sent. Populated for ORG, GROUP, and USER notifications types.
notifications.username string Name of the Atlas user to which to send notifications. Only a user in the project that owns the alert configuration is allowed here. Populated for the USER notifications type.
notifications.teamId string Unique identifier of a team.
notifications.emailAddress string Email address to which alert notifications should be sent. Populated for the EMAIL notifications type.
notifications.mobileNumber string Mobile number to which alert notifications should be sent. Populated for the SMS notifications type.
notifications.notificationToken string HipChat API token. Populated for the HIP_CHAT notifications types. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
notifications.roomName string HipChat room name. Populated for the HIP_CHAT notifications type.
notifications.channelName string Slack channel name. Populated for the SLACK notifications type.
notifications.apiToken string Slack API token or Bot token. Populated for the SLACK notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
notifications.orgName string Flowdock organization name in lower-case letters. This is the name that appears after www.flowdock.com/app/ in the URL string. Populated for the FLOWDOCK notifications type.
notifications.flowName string

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>.

Populated for the FLOWDOCK notifications type.

notifications.flowdockApiToken string The Flowdock personal API token. Populated for the FLOWDOCK notifications type. If the token later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.
notifications.serviceKey string PagerDuty service key. Populated 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.
notifications.victorOpsApiKey string VictorOps API key. Populated for the VICTOR_OPS notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key.
notifications.victorOpsRoutingKey string VictorOps routing key. Populated for the VICTOR_OPS notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the key.
notifications.opsGenieApiKey string OpsGenie API Key. Populated for the OPS_GENIE notifications type. If the key later becomes invalid, Atlas sends an email to the project owner and eventually removes the token.

Example Request

curl -X POST -u "username:apiKey" --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups/535683b3794d371327b/alertConfigs" \
   -H "Content-Type: application/json" --data '
   {
     "eventTypeName" : "NO_PRIMARY",
     "enabled" : true,
     "notifications" : [ {
       "typeName" : "GROUP",
       "intervalMin" : 5,
       "delayMin" : 0,
       "smsEnabled" : false,
       "emailEnabled" : true
     } ]
   }'

Example Response

{
  "id" : "57b76ddc96e8215c017ceafb",
  "created" : "2016-08-19T20:36:44Z",
  "enabled" : true,
  "eventTypeName" : "NO_PRIMARY",
  "groupId" : "535683b3794d371327b",
  "matchers" : [ ],
  "notifications" : [ {
    "delayMin" : 0,
    "emailEnabled" : true,
    "intervalMin" : 5,
    "smsEnabled" : false,
    "typeName" : "GROUP"
  } ],
  "updated" : "2016-08-19T20:36:44Z",
  "links" : [ ... ]
}