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. This page uses the more familiar term group when referring to descriptions. The endpoint remains as stated in the document.

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

Resource

POST /groups/{GROUP-ID}/alertConfigs

Request Path Parameters

Parameter Type Description
GROUP-ID string (Required.) Group identifier.

Request Query Parameters

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

Name Type Description Default
pretty boolean Indicates whether the response body should be in a prettyprint format. false
envelope boolean

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 one result, the response body includes:

status
HTTP response code
envelope
The expected response body
false

Request Body Parameters

Note

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

Name Type Description
enabled boolean If omitted, the configuration is disabled.
eventTypeName string

Required. The type of event that triggers an alert.

  • Host alerts support these values:
    • HOST_DOWN
    • HOST_RECOVERING
    • VERSION_BEHIND
    • HOST_EXPOSED
    • OUTSIDE_METRIC_THRESHOLD
  • Agent alerts support these values:
    • MONITORING_AGENT_DOWN
    • MONITORING_AGENT_VERSION_BEHIND
    • BACKUP_AGENT_DOWN
    • BACKUP_AGENT_VERSION_BEHIND
    • BACKUP_AGENT_CONF_CALL_FAILURE
  • Backup alerts support these values:
    • OPLOG_BEHIND
    • CLUSTER_MONGOS_IS_MISSING
    • RESYNC_REQUIRED
    • BAD_CLUSTERSHOTS
  • Project alerts support these values:
    • USERS_AWAITING_APPROVAL
    • USERS_WITHOUT_MULTI_FACTOR_AUTH
  • Replica set alerts support these values:
    • CONFIGURATION_CHANGED
    • PRIMARY_ELECTED
    • TOO_FEW_HEALTHY_MEMBERS
    • TOO_MANY_UNHEALTHY_MEMBERS
    • NO_PRIMARY
  • Sharded cluster alerts support this value:
    • CLUSTER_MONGOS_IS_MISSING
  • User alerts support these values:
    • JOINED_GROUP
    • REMOVED_FROM_GROUP
matchers.fieldName string

The name of the field in the target object to match on.

  • Host alerts support these fields:
    • HOSTNAME
    • PORT
    • HOSTNAME_AND_PORT
    • REPLICA_SET_NAME
    • TYPE_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

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

metricThreshold.metricName string The name of the metric to check. Supports the same values as the metricName field of the alerts resource.
metricThreshold.mode string Set to AVERAGE to compute the current metric value as an average.
metricThreshold.operator string

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

  • GREATER_THAN
  • LESS_THAN
metricThreshold.threshold number The threshold value outside of which an alert is 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 object The threshold that will cause an alert to be triggered. Required if eventTypeName is OUTSIDE_METRIC_THRESHOLD.
notifications.apiToken string The Slack API token or Bot token. For SLACK notifications. If the token later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the token.
notifications.channelName string The Slack channel name. For SLACK notifications.
notifications.datadogApiKey string DataDog API Key. Found in the DataDog dashboard. Only present for notifications of type DATADOG.
notifications.delayMin number The number of minutes to wait after an alert condition is detected before sending out the first notification.
notifications.emailAddress string The email address to which to send notification. For notifications of type EMAIL.
notifications.emailEnabled boolean Determines if email notifications should be sent. For notifications of type GROUP and USER.
notifications.flowdockApiToken string The Flowdock “personal API token.” For FLOWDOCK notifications. If the token later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the token.
notifications.flowName string The flow name, in lower-case letters. For FLOWDOCK notifications. The flow name appears after the organization name in the URL string: www.flowdock.com/app/<organization-name>/<flow-name>.
notifications.intervalMin number The number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved.
notifications.mobileNumber string Mobile number to send SMS messages to. For notifications of type SMS.
notifications.notificationToken string A HipChat API token. For notifications of type HIP_CHAT. If the token later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the token.
notifications.orgName string The Flowdock organization name in lower-case letters. This is the name that appears after www.flowdock.com/app/ in the URL string. For FLOWDOCK notifications.
notifications.roomName string HipChat room name. For notifications of type HIP_CHAT.
notifications.serviceKey string PagerDuty service key.
notifications.smsEnabled boolean Determines if SMS notifications should be sent. For notifications of type GROUP and USER.
notifications.teamId string The unique identifier of a team.
notifications.typeName string

The type of alert notification. Accepted values are:

  • EMAIL
  • FLOWDOCK
  • GROUP
  • HIPCHAT
  • PAGER_DUTY
  • SLACK
  • SMS
  • TEAM
  • USER
  • WEBHOOK
notifications.username string The name of a Cloud Manager user to which to send notifications. Specify a user in the group that owns the alert configuration. For notifications of type USER.
notifications object array Required. Notifications to send when an alert condition is detected.
threshold.operator string

The operator to apply when checking the current metric value against the threshold value.

  • GREATER_THAN
  • LESS_THAN
threshold.threshold number The threshold value outside of which an alert is triggered.
threshold object

The threshold that will cause an alert to be triggered. Required if eventTypeName is set to one of the following:

  • TOO_FEW_HEALTHY_MEMBERS
  • TOO_MANY_UNHEALTHY_MEMBERS

Response

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 date When this alert configuration was created.
enabled boolean Is this alert configuration enabled?
eventTypeName string

The type of event that triggers an alert.

  • Host alerts support these values:
    • HOST_DOWN
    • HOST_RECOVERING
    • VERSION_BEHIND
    • HOST_EXPOSED
    • OUTSIDE_METRIC_THRESHOLD
  • Agent alerts support these values:
    • MONITORING_AGENT_DOWN
    • MONITORING_AGENT_VERSION_BEHIND
    • BACKUP_AGENT_DOWN
    • BACKUP_AGENT_VERSION_BEHIND
    • BACKUP_AGENT_CONF_CALL_FAILURE
  • Backup alerts support these values:
    • OPLOG_BEHIND
    • CLUSTER_MONGOS_IS_MISSING
    • RESYNC_REQUIRED
    • BAD_CLUSTERSHOTS
  • Project alerts support these values:
    • USERS_AWAITING_APPROVAL
    • USERS_WITHOUT_MULTI_FACTOR_AUTH
  • Replica set alerts support these values:
    • CONFIGURATION_CHANGED
    • PRIMARY_ELECTED
    • TOO_FEW_HEALTHY_MEMBERS
    • TOO_MANY_UNHEALTHY_MEMBERS
    • NO_PRIMARY
  • Sharded cluster alerts support this value:
    • CLUSTER_MONGOS_IS_MISSING
  • User alerts support these values:
    • JOINED_GROUP
    • REMOVED_FROM_GROUP
groupId string ID of the group that owns this alert configuration.
id string Unique identifier.
matchers.fieldName string

The name of the field in the target object to match on.

  • Host alerts support these fields:
    • HOSTNAME
    • PORT
    • HOSTNAME_AND_PORT
    • REPLICA_SET_NAME
    • TYPE_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

The 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
matchers object array Rules to apply when matching an object against this alert configuration. Only entities that match all these rules will be 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.
metricThreshold.metricName string The name of the metric to check. Supports the same values as the metricName field of the alerts resource.
metricThreshold.mode string This is set to AVERAGE and computes the current metric value as an average.
metricThreshold.operator string

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

  • GREATER_THAN
  • LESS_THAN
metricThreshold.threshold number The threshold value outside of which an alert is 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 object The threshold that triggers an alert. Only present if eventTypeName is set to OUTSIDE_METRIC_THRESHOLD.
notifications.apiToken string The Slack API token or Bot token. Only present for SLACK notifications. If the token later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the token.
notifications.channelName string The Slack channel name. Only present for SLACK notifications.
notifications.datadogApiKey string DataDog API Key. Found in the DataDog dashboard. Only present for notifications of type DATADOG.
notifications.delayMin number The number of minutes to wait after an alert condition is detected before sending out the first notification.
notifications.emailAddress string The email address to which to send notification. Only present for notifications of type EMAIL.
notifications.emailEnabled boolean Should email notifications be sent? Only present for notifications of type GROUP and USER.
notifications.flowdockApiToken string The Flowdock “personal API token.” Only present for FLOWDOCK notifications. If the token later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the token.
notifications.flowName string The flow name, in lower-case letters. Only present for FLOWDOCK notifications. The flow name appears after the organization name in the URL string: www.flowdock.com/app/<organization-name>/<flow-name>.
notifications.intervalMin number The number of minutes to wait between successive notifications for unacknowledged alerts that are not resolved.
notifications.mobileNumber string Mobile number to send SMS messages to. Only present for notifications of type SMS.
notifications.notificationToken string A HipChat API token. Only present for notifications of type HIP_CHAT. If the token later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the token.
notifications.orgName string The Flowdock organization name in lower-case letters. This is the name that appears after www.flowdock.com/app/ in the URL string. Only present for FLOWDOCK notifications.
notifications.roomName string HipChat room name. Only present for notifications of type HIP_CHAT.
notifications.serviceKey string PagerDuty service key. Only present for PAGER_DUTY notifications. If the key later becomes invalid, Cloud Manager sends an email to the group owner and eventually removes the key.
notifications.smsEnabled boolean Should SMS notifications be sent? Only present for notifications of type GROUP and USER.
notifications.teamId string The unique identifier of a team.
notifications.typeName string

The type of alert notification. Accepted values are:

  • EMAIL
  • FLOWDOCK
  • GROUP
  • HIPCHAT
  • PAGER_DUTY
  • SLACK
  • SMS
  • TEAM
  • USER
  • WEBHOOK
notifications.username string The name of a Cloud Manager user to which to send notifications. Only a user in the group that owns the alert configuration is allowed here. Only present for notifications of type USER.
notifications object array Notifications to send when an alert condition is detected.
threshold.operator string

The operator to apply when checking the current metric value against the threshold value.

  • GREATER_THAN
  • LESS_THAN
threshold.threshold number The threshold value outside of which an alert is triggered.
threshold object

The threshold that triggers an alert. Only presen if eventTypeName is set to one of the following:

  • TOO_FEW_HEALTHY_MEMBERS
  • TOO_MANY_UNHEALTHY_MEMBERS
typeName string This field is deprecated and is ignored.
updated date When this alert configuration was last updated.

Example Request

curl --user "{USERNAME}:{APIKEY}" --digest \
 --header "Accept: application/json" \
 --header "Content-Type: application/json" \
 --include \
 --request POST "https://cloud.mongodb.com/api/public/v1.0/groups/4d1b6314e528c81a1f200e03/alertConfigs" \
 --data '
   {
     "groupId" : "4d1b6314e528c81a1f200e03",
     "eventTypeName" : "RESYNC_REQUIRED",
     "enabled" : true,
     "notifications" : [ {
       "typeName" : "GROUP",
       "intervalMin" : 5,
       "delayMin" : 0,
       "smsEnabled" : false,
       "emailEnabled" : true
     } ]
   }'

Example Response

Response Header

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=ISO-8859-1
Date: {dateInUnixFormat}
WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=false
Content-Length: {requestLengthInBytes}
Connection: keep-alive
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Type: application/json
Strict-Transport-Security: max-age=300
Date: {dateInUnixFormat}
Connection: keep-alive
Content-Length: {requestLengthInBytes}

Response Body

{
  "id" : "{ALERT-CONFIG-ID}",
  "groupId" : "{GROUP-ID}",
  "created" : "2014-04-23T14:29:18Z",
  "updated" : "2014-04-23T14:29:18Z",
  "enabled" : true,
  "matchers" : [ ],
  "notifications" : [ {
    "typeName" : "GROUP",
    "intervalMin" : 5,
    "delayMin" : 0,
    "emailEnabled" : true,
    "smsEnabled" : false
  } ],
  "links" : []
}