|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * monitoring/configuring-the-monitoring-stack.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="monitoring-adding-a-secret-to-the-alertmanager-configuration_{context}"] |
| 7 | += Adding a secret to the Alertmanager configuration |
| 8 | + |
| 9 | +You can add secrets to the Alertmanager configuration for core platform monitoring components by editing the `cluster-monitoring-config` config map in the `openshift-monitoring` project. |
| 10 | +You can add secrets to the Alertmanager configuration for user-defined projects by editing the `user-workload-monitoring-config` config map in the `openshift-user-workload-monitoring` project. |
| 11 | + |
| 12 | +After you add a secret to the config map, the secret is mounted as a volume at `/etc/alertmanager/secrets/<secret_name>` within the `alertmanager` container for the Alertmanager pods. |
| 13 | + |
| 14 | +.Prerequisites |
| 15 | + |
| 16 | +* You have installed the OpenShift CLI (`oc`). |
| 17 | +* *If you are configuring core {product-title} monitoring components in the `openshift-monitoring` project*: |
| 18 | +** You have access to the cluster as a user with the `cluster-admin` role. |
| 19 | +** You have created the `cluster-monitoring-config` config map. |
| 20 | +** You have created the secret to be configured in Alertmanager in the `openshift-monitoring` project. |
| 21 | +* *If you are configuring components that monitor user-defined projects*: |
| 22 | +** A cluster administrator has enabled monitoring for user-defined projects. |
| 23 | +** You have access to the cluster as a user with the `cluster-admin` role, or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project. |
| 24 | +** You have created the secret to be configured in Alertmanager in the `openshift-user-workload-monitoring` project. |
| 25 | +
|
| 26 | +.Procedure |
| 27 | + |
| 28 | +. To add a secret configuration to Alertmanager for core platform monitoring, edit the `cluster-monitoring-config` config map in the `openshift-monitoring` project: |
| 29 | ++ |
| 30 | +[source,terminal] |
| 31 | +---- |
| 32 | +$ oc -n openshift-monitoring edit configmap cluster-monitoring-config |
| 33 | +---- |
| 34 | + |
| 35 | +. Add a `secrets:` section under `data/config.yaml/alertmanagerMain`. |
| 36 | + |
| 37 | +. Add the configuration details for the secret in this section: |
| 38 | ++ |
| 39 | +[source,yaml] |
| 40 | +---- |
| 41 | +apiVersion: v1 |
| 42 | +kind: ConfigMap |
| 43 | +metadata: |
| 44 | + name: cluster-monitoring-config |
| 45 | + namespace: openshift-monitoring |
| 46 | +data: |
| 47 | + config.yaml: | |
| 48 | + alertmanagerMain: |
| 49 | + secrets: <1> |
| 50 | + - <secret_name_1> <2> |
| 51 | + - <secret_name_2> |
| 52 | +---- |
| 53 | +<1> This section contains the secrets to be mounted into Alertmanager. |
| 54 | +The secrets must be located within the same namespace as the Alertmanager object. |
| 55 | +<2> The name of the `Secret` object that contains authentication credentials for the receiver. |
| 56 | +If you add multiple secrets, place each one on a new line. |
| 57 | ++ |
| 58 | +The following sample config map settings configure Alertmanager to use two `Secret` objects named `test-secret-basic-auth` and `test-secret-api-token`: |
| 59 | ++ |
| 60 | +[source,yaml] |
| 61 | +---- |
| 62 | +apiVersion: v1 |
| 63 | +kind: ConfigMap |
| 64 | +metadata: |
| 65 | + name: cluster-monitoring-config |
| 66 | + namespace: openshift-monitoring |
| 67 | +data: |
| 68 | + config.yaml: | |
| 69 | + alertmanagerMain: |
| 70 | + secrets: |
| 71 | + - test-secret-basic-auth |
| 72 | + - test-secret-api-token |
| 73 | +---- |
| 74 | + |
| 75 | +. Optional: To add the secrets for use by Alertmanager in user-defined projects, add the secret names under `data/config.yaml/alertmanager/secrets` in the `user-workload-monitoring-config` config map in the `openshift-user-workload-monitoring` project: |
| 76 | ++ |
| 77 | +[source,yaml] |
| 78 | +---- |
| 79 | +apiVersion: v1 |
| 80 | +kind: ConfigMap |
| 81 | +metadata: |
| 82 | + name: user-workload-monitoring-config |
| 83 | + namespace: openshift-user-workload-monitoring |
| 84 | +data: |
| 85 | + config.yaml: | |
| 86 | + alertmanager: |
| 87 | + enabled: true |
| 88 | + secrets: |
| 89 | + - test-secret |
| 90 | + - test-api-receiver-token |
| 91 | +---- |
| 92 | ++ |
| 93 | +[NOTE] |
| 94 | +==== |
| 95 | +Configurations applied to the `user-workload-monitoring-config` `ConfigMap` object are not activated unless a cluster administrator has enabled monitoring for user-defined projects. |
| 96 | +==== |
| 97 | + |
| 98 | +. Save the file to apply the changes to the `ConfigMap` object. |
| 99 | +The new configuration is applied automatically. |
| 100 | + |
0 commit comments