|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * observability/monitoring/managing-alerts.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="configuring-notifications-for-default-platform-alerts_{context}"] |
| 7 | += Configuring notifications for default platform alerts |
| 8 | + |
| 9 | +You can configure Alertmanager to send notifications. Customize where and how Alertmanager sends notifications about default platform alerts by editing the default configuration in the `alertmanager-main` secret in the `openshift-monitoring` namespace. |
| 10 | + |
| 11 | +[IMPORTANT] |
| 12 | +==== |
| 13 | +Alertmanager does not send notifications by default. It is recommended to configure Alertmanager to receive notifications by setting up notifications details in the `alertmanager-main` secret configuration file. |
| 14 | +==== |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +* You have access to the cluster as a user with the `cluster-admin` cluster role. |
| 19 | +
|
| 20 | +.Procedure |
| 21 | + |
| 22 | +. Open the Alertmanager YAML configuration file: |
| 23 | + |
| 24 | +** To open the Alertmanager configuration from the CLI: |
| 25 | + |
| 26 | +.. Print the currently active Alertmanager configuration from the `alertmanager-main` secret into `alertmanager.yaml` file: |
| 27 | ++ |
| 28 | +[source,terminal] |
| 29 | +---- |
| 30 | +$ oc -n openshift-monitoring get secret alertmanager-main --template='{{ index .data "alertmanager.yaml" }}' | base64 --decode > alertmanager.yaml |
| 31 | +---- |
| 32 | + |
| 33 | +.. Open the `alertmanager.yaml` file. |
| 34 | + |
| 35 | +** To open the Alertmanager configuration from the {product-title} web console: |
| 36 | + |
| 37 | +.. Go to the *Administration* -> *Cluster Settings* -> *Configuration* -> *Alertmanager* -> *YAML* page of the web console. |
| 38 | + |
| 39 | +. Edit the Alertmanager configuration by updating parameters in the YAML: |
| 40 | ++ |
| 41 | +[source,yaml] |
| 42 | +---- |
| 43 | +global: |
| 44 | + resolve_timeout: 5m |
| 45 | +route: |
| 46 | + group_wait: 30s #<1> |
| 47 | + group_interval: 5m #<2> |
| 48 | + repeat_interval: 12h #<3> |
| 49 | + receiver: default |
| 50 | + routes: |
| 51 | + - matchers: |
| 52 | + - "alertname=Watchdog" |
| 53 | + repeat_interval: 2m |
| 54 | + receiver: watchdog |
| 55 | + - matchers: |
| 56 | + - "service=<your_service>" #<4> |
| 57 | + routes: |
| 58 | + - matchers: |
| 59 | + - <your_matching_rules> #<5> |
| 60 | + receiver: <receiver> #<6> |
| 61 | +receivers: |
| 62 | +- name: default |
| 63 | +- name: watchdog |
| 64 | +- name: <receiver> |
| 65 | + <receiver_configuration> #<7> |
| 66 | +---- |
| 67 | +<1> Specify how long Alertmanager waits while collecting initial alerts for a group of alerts before sending a notification. |
| 68 | +<2> Specify how much time must elapse before Alertmanager sends a notification about new alerts added to a group of alerts for which an initial notification was already sent. |
| 69 | +<3> Specify the minimum amount of time that must pass before an alert notification is repeated. |
| 70 | +If you want a notification to repeat at each group interval, set the `repeat_interval` value to less than the `group_interval` value. |
| 71 | +The repeated notification can still be delayed, for example, when certain Alertmanager pods are restarted or rescheduled. |
| 72 | +<4> Specify the name of the service that fires the alerts. |
| 73 | +<5> Specify labels to match your alerts. |
| 74 | +<6> Specify the name of the receiver to use for the alerts. |
| 75 | +<7> Specify the receiver configuration. |
| 76 | ++ |
| 77 | +[IMPORTANT] |
| 78 | +==== |
| 79 | +* Use the `matchers` key name to indicate the matchers that an alert has to fulfill to match the node. |
| 80 | +Do not use the `match` or `match_re` key names, which are both deprecated and planned for removal in a future release. |
| 81 | +
|
| 82 | +* If you define inhibition rules, use the following key names: |
| 83 | ++ |
| 84 | +-- |
| 85 | +** `target_matchers`: to indicate the target matchers |
| 86 | +** `source_matchers`: to indicate the source matchers |
| 87 | +-- |
| 88 | ++ |
| 89 | +Do not use the `target_match`, `target_match_re`, `source_match`, or `source_match_re` key names, which are deprecated and planned for removal in a future release. |
| 90 | +==== |
| 91 | ++ |
| 92 | +The following Alertmanager configuration example configures PagerDuty as an alert receiver: |
| 93 | ++ |
| 94 | +[source,yaml] |
| 95 | +---- |
| 96 | +global: |
| 97 | + resolve_timeout: 5m |
| 98 | +route: |
| 99 | + group_wait: 30s |
| 100 | + group_interval: 5m |
| 101 | + repeat_interval: 12h |
| 102 | + receiver: default |
| 103 | + routes: |
| 104 | + - matchers: |
| 105 | + - "alertname=Watchdog" |
| 106 | + repeat_interval: 2m |
| 107 | + receiver: watchdog |
| 108 | + - matchers: |
| 109 | + - "service=example-app" |
| 110 | + routes: |
| 111 | + - matchers: |
| 112 | + - "severity=critical" |
| 113 | + receiver: team-frontend-page |
| 114 | +receivers: |
| 115 | +- name: default |
| 116 | +- name: watchdog |
| 117 | +- name: team-frontend-page |
| 118 | + pagerduty_configs: |
| 119 | + - service_key: "<your_key>" |
| 120 | +---- |
| 121 | ++ |
| 122 | +With this configuration, alerts of `critical` severity that are fired by the `example-app` service are sent through the `team-frontend-page` receiver. Typically, these types of alerts would be paged to an individual or a critical response team. |
| 123 | +
|
| 124 | +. Apply the new configuration in the file: |
| 125 | + |
| 126 | +** To apply the changes from the CLI, run the following command: |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +---- |
| 130 | +$ oc -n openshift-monitoring create secret generic alertmanager-main --from-file=alertmanager.yaml --dry-run=client -o=yaml | oc -n openshift-monitoring replace secret --filename=- |
| 131 | +---- |
| 132 | + |
| 133 | +** To apply the changes from the {product-title} web console, click *Save*. |
0 commit comments