|
| 1 | +# alertmanager |
| 2 | + |
| 3 | +Deploy [alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/) |
| 4 | +to route Prometheus alerts to a receiver. Currently Slack is the only supported |
| 5 | +receiver. |
| 6 | + |
| 7 | +Note that: |
| 8 | +- HA configuration is not supported |
| 9 | +- Alertmanager state is not preserved when the node it runs on (by default, |
| 10 | + control node) is reimaged, so any alerts silenced via the GUI will reoccur. |
| 11 | +- No Grafana dashboard for alerts is currently provided. |
| 12 | + |
| 13 | +Alertmanager is enabled by default on the `control` node in the |
| 14 | +[everything](../../../environments/common/layouts/everything) template which |
| 15 | +`cookiecutter` uses for a new environment's `inventory/groups` file. |
| 16 | + |
| 17 | +In general usage may only require: |
| 18 | +- Adding the `control` node into the `alertmanager` group in `environments/site/groups` |
| 19 | + if upgrading an existing environment. |
| 20 | +- Enabling the Slack integration (see section below). |
| 21 | +- Possibly setting `alertmanager_web_external_url`. |
| 22 | + |
| 23 | +The web UI is available on `alertmanager_web_external_url`. |
| 24 | + |
| 25 | +## Role variables |
| 26 | + |
| 27 | +All variables are optional. See [defaults/main.yml](defaults/main.yml) for |
| 28 | +all default values. |
| 29 | + |
| 30 | +General variables: |
| 31 | +- `alertmanager_version`: String, version (no leading 'v') |
| 32 | +- `alertmanager_download_checksum`: String, checksum for relevant version from |
| 33 | + [prometheus.io download page](https://prometheus.io/download/), in format |
| 34 | + `type:value`. |
| 35 | +- `alertmanager_download_dest`: String, path of temporary directory used for |
| 36 | + download. Must exist. |
| 37 | +- `alertmanager_binary_dir`: String, path of directory to install alertmanager |
| 38 | + binary to. Must exist. |
| 39 | +- `alertmanager_started`: Bool, whether the alertmanager service should be started. |
| 40 | +- `alertmanager_enabled`: Bool, whether the alertmanager service should be enabled. |
| 41 | +- `alertmanager_system_user`: String, name of user to run alertmanager as. Will be created. |
| 42 | +- `alertmanager_system_group`: String, name of group of alertmanager user. |
| 43 | +- `alertmanager_port`: Port to listen on. |
| 44 | + |
| 45 | +The following variables are equivalent to similarly-named arguments to the |
| 46 | +`alertmanager` binary. See `man alertmanager` for more info: |
| 47 | + |
| 48 | +- `alertmanager_config_file`: String, path the main alertmanager config file |
| 49 | + will be written to. Parent directory will be created if necessary. |
| 50 | +- `alertmanager_web_config_file`: String, path alertmanager web config file |
| 51 | + will be written to. Parent directory will be created if necessary. |
| 52 | +- `alertmanager_storage_path`: String, base path for data storage. |
| 53 | +- `alertmanager_web_listen_addresses`: List of strings, defining addresses to listeen on. |
| 54 | +- `alertmanager_web_external_url`: String, the URL under which Alertmanager is |
| 55 | + externally reachable - defaults to host IP address and `alertmanager_port`. |
| 56 | + See man page for more details if proxying alertmanager. |
| 57 | +- `alertmanager_data_retention`: String, how long to keep data for |
| 58 | +- `alertmanager_data_maintenance_interval`: String, interval between garbage |
| 59 | + collection and snapshotting to disk of the silences and the notification logs. |
| 60 | +- `alertmanager_config_flags`: Mapping. Keys/values in here are written to the |
| 61 | + alertmanager commandline as `--{{ key }}={{ value }}`. |
| 62 | +- `alertmanager_default_receivers`: |
| 63 | + |
| 64 | +The following variables are templated into the alertmanager [main configuration](https://prometheus.io/docs/alerting/latest/configuration/): |
| 65 | +- `alertmanager_config_template`: String, path to configuration template. The default |
| 66 | + is to template in `alertmanager_config_default` and `alertmanager_config_extra`. |
| 67 | +- `alertmanager_config_default`: Mapping with default configuration for the |
| 68 | + top-level `route` and `receivers` keys. The default is to send all alerts to |
| 69 | + the Slack receiver, if that has been enabled (see below). |
| 70 | +- `alertmanager_receivers`: A list of [receiver](https://prometheus.io/docs/alerting/) |
| 71 | + mappings to define under the top-level `receivers` configuration key. This |
| 72 | + will contain the Slack receiver if that has been enabled (see below). |
| 73 | +- `alertmanager_extra_receivers`: A list of additional [receiver](https://prometheus.io/docs/alerting/), |
| 74 | + mappings to add, by default empty. |
| 75 | +- `alertmanager_slack_receiver`: Mapping defining the [Slack receiver](https://prometheus.io/docs/alerting/latest/configuration/#slack_config). Note the default configuration for this is in |
| 76 | +`environments/common/inventory/group_vars/all/alertmanager.yml`. |
| 77 | +- `alertmanager_slack_receiver_name`: String, name for the above Slack reciever. |
| 78 | +- `alertmanager_slack_receiver_send_resolved`: Bool, whether to send resolved alerts via the above Slack reciever. |
| 79 | +- `alertmanager_null_receiver`: Mapping defining a `null` [receiver](https://prometheus.io/docs/alerting/latest/configuration/#receiver) so a receiver is always defined. |
| 80 | +- `alertmanager_config_extra`: Mapping with additional configuration. Keys in |
| 81 | + this become top-level keys in the configuration. E.g this might be: |
| 82 | + ```yaml |
| 83 | + alertmanager_config_extra: |
| 84 | + global: |
| 85 | + smtp_from: smtp.example.org:587 |
| 86 | + time_intervals: |
| 87 | + - name: monday-to-friday |
| 88 | + time_intervals: |
| 89 | + - weekdays: ['monday:friday'] |
| 90 | + ``` |
| 91 | + Note that `route` and `receivers` keys should not be added here. |
| 92 | + |
| 93 | +The following variables are templated into the alertmanager [web configuration](https://prometheus.io/docs/alerting/latest/https/): |
| 94 | +- `alertmanager_web_config_default`: Mapping with default configuration for |
| 95 | + `basic_auth_users` providing the default web user. |
| 96 | +- `alertmanager_alertmanager_web_config_extra`: Mapping with additional web |
| 97 | + configuration. Keys in this become top-level keys in the web configuration. |
0 commit comments