mongocli atlas alerts settings create
The alerts settings create
command creates one alert configuration
in the specified Atlas project. You can also create one alert
configuration in a project through the Atlas API.
Syntax
mongocli atlas alert|alerts settings|configs create [ --event <event> ] [ --enabled ] [ --matcherField <fieldName> ] [ --matcherOperator <operator> ] [ --matcherValue <value> ] [ --notification* (notification flags) ] [ --output|-o <output-format> ] [ --projectId <id-of-project> ] [ --profile|-P <profile-name> ]
Note
Use -h
or --help
to view the command-line help for
this command.
Options
Option | Type | Description | Required? |
---|---|---|---|
--apiKey | string | Datadog, OpsGenie, or VictorOps API key. | only if notificationType is DATADOG, ``OPS_GENIE , or VICTOR_OPS . |
--enabled | boolean | Flag that determines whether the alert configuration is enabled.
If present, the alert configuration is enabled. If omitted, the
configuration is disabled. | no |
--event | string | Type of event that triggers an alert. For a complete list of alert events, see Alert Conditions. | yes |
--matcherFieldName | string | Name of the field in the target object to match on. Use the List alert configuration matcher fields to return the accepted values. | no |
--matcherOperator | string | Operator to test the field's value. Accepted values are:
| no |
--matcherValue | string | Value to test with the specified operator. If
| no |
--metricMode | string | Set to AVERAGE to compute the average of this metric. | no |
--metricName | string | The name of the metric whose value went outside the threshold. Only
applicable if
| only if --event is OUTSIDE_METRIC_THRESHOLD . |
--metricOperator | string | Operator to apply when checking the current metric value against the threshold value. Accepted values are:
| no |
--metricThreshold | float | Threshold value outside of which an alert is triggered. | no |
--metricUnits | string | Units for the threshold value. Depends on the type of metric. ExampleA metric that measures memory consumption would have a byte measurement, while a metric that measures time would have a time unit. Accepted values are:
| no |
--notificationToken | string | Slack API or Bot token or Flowdock personal API token.
If the token later becomes invalid, Ops Manager sends an email to
the Project owner and eventually removes the token. | only if notificationType is SLACK or FLOWDOCK . |
--notificationChannelName | string | Slack channel name. | only if notificationType is SLACK . |
--notificationdelayMin | int | Minutes to wait after an alert condition is detected before
sending out the first notification. | no |
--notificationEmailAddress | string | Email address to which Atlas sends notifications. | only if notificationType is EMAIL . |
--notificationEmailEnabled | boolean | Flag determining if Atlas sends email notifications.
If present, Atlas sends email notifications. If absent,
Atlas doesn't send email notifications.
Configurable for GROUP and USER notifications types. | no |
--notificationsFlowName | string | 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> . | only if notificationType is ``FLOWDOCK . |
--notificationIntervalMin | int | Minutes to wait between successive notifications
for unacknowledged alerts that are not resolved. | no |
--notificationMobileNumber | string | Mobile number to send SMS messages to. | only if notificationType is SMS . |
--notificationOrgName | string | Flowdock organization name in lower-case letters. This is
the name that appears after www.flowdock.com/app/ in the
URL string. | only if notificationType is FLOWDOCK . |
--notificationRole | string | One or more project roles that receive the configured alert. Accepted values include:
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. Configurable for | no |
--notificationServiceKey | string | PagerDuty service key. | only if notificationType is PAGER_DUTY . |
--notificationSmsEnabled | boolean | Flag indicating SMS notifications must be sent. | only if:
|
--notificationTeamId | string | Unique identifier of a team. | no |
--notificationType | string | Type of alert notification. Accepted values are:
| yes |
--notificationUsername | string | Name of an Atlas user to which to send notifications.
Specify a user in the Project that owns the alert
configuration. | Only if notificationType is USER . |
--notificationVictorOpsRoutingKey | string | VictorOps routing key | Only if notificationType is VICTOR_OPS . |
--output , -o | string | Command output format. Valid values are:
If omitted, the command returns output in the default format. | no |
--profile , -P | string | Name of the profile where the public and private
keys for the project are saved. If omitted, uses the default profile. To learn more about creating a
profile, see Configure the MongoDB CLI. | no |
--projectId | string | Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable. NoteYou can retrieve the list of projects, including their IDs, using
the | yes |
Output
If the command succeeds, it prints the subset of the following fields to the terminal in the specified format that describes the alert configuration. If the command returns an error, see Troubleshooting for recommended solutions.
Name | Type | Description |
---|---|---|
id | string | Unique identifier of the alert configuration. |
groupId | string | Unique identifier of the project that owns this alert
configuration. |
eventTypeName | string | Type of event that triggers an alert. For a complete list of alert events, see Alert Conditions. |
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 If |
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 .fieldName | string | Name of the field in the target object to match on.
All other types of alerts do not support matchers. |
matchers .operator | string | Operator to test the field's value. Accepted values are:
|
matchers .value | string | Value to test with the specified operator. If
|
metricThreshold | object | Threshold that causes an alert to be triggered.
Populated if "eventTypeName" :
"OUTSIDE_METRIC_THRESHOLD" . |
metricThreshold .metricName | string | The name of the metric whose value went outside the threshold. Only
applicable if
|
metricThreshold .operator | string | Operator to apply when checking the current metric value against the threshold value. Accepted values are:
|
metricThreshold .threshold | integer | Threshold value outside of which an alert will be triggered. |
metricThreshold .units | string | Units for the threshold value. Depends on the type of metric. ExampleA metric that measures memory consumption would have a byte measurement, while a metric that measures time would have a time unit. Accepted values are:
|
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:
|
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.
Returned with ORG , GROUP , and USER notifications
types. |
notifications .smsEnabled | boolean | Flag indicating if text message notifications should be sent.
Returned with 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. Returned with the USER notifications
type. |
notifications .roles | array of strings | One or more project roles that receive the configured alert. Accepted values include:
|
notifications .teamId | string | Unique identifier of a team. |
notifications .emailAddress | string | Email address to which alert notifications are sent.
Returned with the EMAIL notifications type. |
notifications .mobileNumber | string | Mobile number to which alert notifications are sent.
Returned with the SMS notifications type. |
notifications .channelName | string | Slack channel name.
Returned with the SLACK notifications type. |
notifications .apiToken | string | Slack API token or Bot token.
Returned with 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. Returned with 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:
Returned with the |
notifications .flowdockApiToken | string | Flowdock personal API token. Returned with 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. Returned with 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.
Returned with 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.
Returned with 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. Returned with the OPS_GENIE
notifications type. If the key later becomes invalid,
Atlas sends an email to the project owner and eventually
removes the token. |
notifications .opsGenieRegion | string | Region that indicates which API URL to use. Accepted regions are:
The default Opsgenie region is |
notifications .datadogApiKey | string | Datadog API Key. Found in the Datadog dashboard. Populated
for the DATADOG notifications type. |
notifications .datadogRegion | string | Region that indicates which API URL to use. Accepted regions are:
The default Datadog region is |
Examples
The following example uses the mongocli atlas alerts settings create
command to create one alert configuration the specified
project. It uses the default profile to access the
Atlas project.
mongocli atlas alert settings create --event JOINED_GROUP --enabled \ --notificationType USER --notificationEmailEnabled \ --notificationUsername john@example.com \ -o json --projectId 5df90590f10fab5e33de2305
The above command prints the following fields in the specified format to the terminal. To learn more about these fields, see Output.
{ "id": "5eaafc90da10757c5fc51e70", "groupId": "5df90590f10fab5e33de2305", "eventTypeName": "JOINED_GROUP", "created": "2020-05-01T14:34:57Z", "updated": "2020-05-01T14:34:57Z", "enabled": true, "notifications": [ { "delayMin": 0, "emailEnabled": true, "smsEnabled": false, "typeName": "USER", "username": "john@example.com" } ] }