github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/docs/guides/alert-manager-configuration.md (about)

     1  ---
     2  title: "Configuring Notification using Cortex Alertmanager"
     3  linkTitle: "Alertmanager configuration"
     4  weight: 10
     5  slug: alertmanager-configuration
     6  ---
     7  
     8  ## Context
     9  
    10  Cortex Alertmanager notification setup follow mostly the syntax of Prometheus Alertmanager since it is based on the same codebase.  The following is a description on how to load the configuration setup so that Alertmanager can use for notification when an alert event happened.
    11  
    12  ### Configuring the Cortex Alertmanager storage backend
    13  
    14  With the introduction of Cortex 1.8 the storage backend config option shifted to the new pattern [#3888](https://github.com/cortexproject/cortex/pull/3888). You can find the new configuration [here](../configuration/config-file-reference.md#alertmanager_storage_config)
    15  
    16  Note that when using `-alertmanager.sharding-enabled=true`, the following storage backends are not supported: `local`, `configdb`.
    17  
    18  When using the new configuration pattern it is important that any of the old configuration pattern flags are unset (`-alertmanager.storage`), as well as `-<prefix>.configs.url`. This is because the old pattern still takes precedence over the new one. The old configuration pattern (`-alertmanager.storage`) is marked as deprecated and will be removed by Cortex version 1.11. However this change doesn't apply to `-alertmanager.storage.path` and `-alertmanager.storage.retention`.
    19  
    20  ### Cortex Alertmanager configuration
    21  
    22  Cortex Alertmanager can be uploaded via Cortex [Set Alertmanager  configuration API](../api/_index.md#set-alertmanager-configuration) or using Grafana Labs [Cortex Tools](https://github.com/grafana/cortex-tools).
    23  
    24  Follow the instruction at the `cortextool` link above to download or update to the latest version of the tool.
    25  
    26  To obtain the full help of how to use `cortextool` for all commands and flags, use
    27  `cortextool --help-long`.
    28  
    29  The following example shows the steps to upload the configuration to Cortex `Alertmanager` using `cortextool`.
    30  
    31  #### 1. Create the Alertmanager configuration `yml` file.
    32  
    33  The following is `amconfig.yml`, an example of a configuration for Cortex `Alertmanager` to send notification via email:
    34  
    35  ```
    36  global:
    37    # The smarthost and SMTP sender used for mail notifications.
    38    smtp_smarthost: 'localhost:25'
    39    smtp_from: 'alertmanager@example.org'
    40    smtp_auth_username: 'alertmanager'
    41    smtp_auth_password: 'password'
    42  
    43  route:
    44    # A default receiver.
    45    receiver: send-email
    46  
    47  receivers:
    48    - name: send-email
    49      email_configs:
    50        - to: 'someone@localhost'
    51  ```
    52  
    53  [Example on how to setup Slack](https://grafana.com/blog/2020/02/25/step-by-step-guide-to-setting-up-prometheus-alertmanager-with-slack-pagerduty-and-gmail/#:~:text=To%20set%20up%20alerting%20in,to%20receive%20notifications%20from%20Alertmanager.) to support receiving Alertmanager notification.
    54  
    55  #### 2. Upload the Alertmanager configuration
    56  
    57  In this example,  Cortex `Alertmanager` is set to be available via localhost on port 8095 with user/org = 100.
    58  
    59  To upload the above configuration `.yml` file with `--key` to be your Basic Authentication or API key:
    60  
    61  ```
    62  cortextool alertmanager load ./amconfig.yml \
    63  --address=http://localhost:8095 \
    64  --id=100 \
    65  --key=<yourKey>
    66  ```
    67  If there is no error reported, the upload is successful.
    68  
    69  To upload the configuration for Cortex `Alertmanager` using Cortex API and curl - see Cortex [Set Alertmanager configuration API](https://cortexmetrics.io/docs/api/#set-alertmanager-configuration).
    70  
    71  #### 3. Ensure the configuration has been uploaded successfully
    72  
    73  ```
    74  cortextool alertmanager get \
    75  --address=http://localhost:8095 \
    76  --id=100 \
    77  --key=<yourKey>
    78  ```