|
| 1 | +.. _atlas-cli-alert-config-file: |
| 2 | + |
| 3 | +======================== |
| 4 | +Alert Configuration File |
| 5 | +======================== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +You can use a configuration file to specify the |
| 14 | +settings for :ref:`creating <atlas-alerts-settings-create>` |
| 15 | +or :ref:`updating <atlas-alerts-settings-update>` an alert |
| 16 | +configuration through the {+atlas-cli+}. The {+atlas-cli+} |
| 17 | +accepts ``.json`` configuration files. |
| 18 | + |
| 19 | +.. _alert-config-settings: |
| 20 | + |
| 21 | +Alert Configuration Settings |
| 22 | +---------------------------- |
| 23 | + |
| 24 | +Depending on the type of alert configuration, you can specify the |
| 25 | +following settings to create or update an alert configuration |
| 26 | +in a configuration file: |
| 27 | + |
| 28 | +.. list-table:: |
| 29 | + :widths: 20 10 70 |
| 30 | + :header-rows: 1 |
| 31 | + |
| 32 | + * - Field |
| 33 | + - Type |
| 34 | + - Description |
| 35 | + |
| 36 | + * - ``enabled`` |
| 37 | + - boolean |
| 38 | + - Flag that indicates whether someone enabled this |
| 39 | + alert configuration for the specified project. |
| 40 | + |
| 41 | + * - ``eventTypeName`` |
| 42 | + - string |
| 43 | + - Required. Event type that triggers an alert. |
| 44 | + |
| 45 | + * - ``matchers`` |
| 46 | + - array of objects |
| 47 | + - Rules to apply when matching an object against this alert |
| 48 | + configuration. You can use this field only if the ``eventTypeName`` |
| 49 | + specifies an event for a host, replica set, or sharded cluster. |
| 50 | + |
| 51 | + * - ``metricThreshold`` |
| 52 | + - object |
| 53 | + - Threshold for the metric that, when exceeded, triggers an alert. |
| 54 | + You can use this field only if the ``eventTypeName`` reflects |
| 55 | + a change in measurement or metric. |
| 56 | + |
| 57 | + * - ``notifications`` |
| 58 | + - array of objects |
| 59 | + - List that contains the targets that |service| sends notifications. |
| 60 | + |
| 61 | + * - ``threshold`` |
| 62 | + - object |
| 63 | + - A limit that triggers an alert when exceeded. |
| 64 | + |
| 65 | +For detailed descriptions and a full list of available settings, |
| 66 | +see the request body schema in the API specification: |
| 67 | + |
| 68 | +- :oas-atlas-op:`Create One Alert Configuration in One Project </createAlertConfiguration>` |
| 69 | +- :oas-atlas-op:`Update One Alert Configuration for One Project </updateAlertConfiguration>` |
| 70 | + |
| 71 | +.. _example-alert-config-file: |
| 72 | + |
| 73 | +Example Alert Configuration File |
| 74 | +-------------------------------- |
| 75 | + |
| 76 | +To create or update an alert configuration, specify the |
| 77 | +fields that you want to include in the configuration file. |
| 78 | +For example, the following sample file enables an alert |
| 79 | +configuration that notifies you when a replica set called |
| 80 | +``event-replica-set`` loses its primary node: |
| 81 | + |
| 82 | +.. literalinclude:: /includes/alert-configuration-config-file.json |
| 83 | + |
| 84 | +Example Alert Configuration Commands |
| 85 | +------------------------------------ |
| 86 | + |
| 87 | +After you create the file, run the {+atlas-cli+} |
| 88 | +command to create or update the alert configuration. |
| 89 | + |
| 90 | +Create an Alert Configuration |
| 91 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 92 | + |
| 93 | +To create an alert configuration, specify the ``--flag`` option |
| 94 | +and the path to the file. The following example creates an |
| 95 | +alert configuration by using a configuration file named |
| 96 | +``alert-config.json``: |
| 97 | + |
| 98 | +.. code-block:: |
| 99 | + |
| 100 | + atlas alerts settings create --file /alert-config.json |
| 101 | + |
| 102 | +Update an Alert Configuration |
| 103 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 104 | + |
| 105 | +To update an alert configuration, specify the ID of the |
| 106 | +alert configuration that you want to update, the ``--flag`` |
| 107 | +option, and the path to the file. The following example updates |
| 108 | +an existing alert configuration by using a configuration file |
| 109 | +named ``alert-config.json``: |
| 110 | + |
| 111 | +.. code-block:: |
| 112 | + |
| 113 | + atlas alerts settings update <alertConfigId> --file /alert-config.json |
0 commit comments