|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * observability/monitoring/configuring-the-monitoring-stack.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="configuring-the-monitoring-stack_{context}"] |
| 7 | += Configuring the monitoring stack |
| 8 | + |
| 9 | +ifndef::openshift-dedicated,openshift-rosa[] |
| 10 | +In {product-title} {product-version}, you can configure the monitoring stack using the `cluster-monitoring-config` or `user-workload-monitoring-config` `ConfigMap` objects. Config maps configure the {cmo-first}, which in turn configures the components of the stack. |
| 11 | +endif::openshift-dedicated,openshift-rosa[] |
| 12 | +ifdef::openshift-dedicated,openshift-rosa[] |
| 13 | +In {product-title}, you can configure the stack that monitors workloads for user-defined projects by using the `user-workload-monitoring-config` `ConfigMap` object. Config maps configure the {cmo-first}, which in turn configures the components of the stack. |
| 14 | +endif::openshift-dedicated,openshift-rosa[] |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +ifndef::openshift-dedicated,openshift-rosa[] |
| 19 | +* *If you are configuring core {product-title} monitoring components*: |
| 20 | +** You have access to the cluster as a user with the `cluster-admin` cluster role. |
| 21 | +** You have created the `cluster-monitoring-config` `ConfigMap` object. |
| 22 | +* *If you are configuring components that monitor user-defined projects*: |
| 23 | +** You have access to the cluster as a user with the `cluster-admin` cluster role, or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project. |
| 24 | +** A cluster administrator has enabled monitoring for user-defined projects. |
| 25 | +endif::openshift-dedicated,openshift-rosa[] |
| 26 | +ifdef::openshift-dedicated,openshift-rosa[] |
| 27 | +* You have access to the cluster as a user with the `dedicated-admin` role. |
| 28 | +* The `user-workload-monitoring-config` `ConfigMap` object exists. This object is created by default when the cluster is created. |
| 29 | +endif::openshift-dedicated,openshift-rosa[] |
| 30 | +* You have installed the OpenShift CLI (`oc`). |
| 31 | + |
| 32 | +.Procedure |
| 33 | + |
| 34 | +. Edit the `ConfigMap` object. |
| 35 | +ifndef::openshift-dedicated,openshift-rosa[] |
| 36 | +** *To configure core {product-title} monitoring components*: |
| 37 | +.. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` project: |
| 38 | ++ |
| 39 | +[source,terminal] |
| 40 | +---- |
| 41 | +$ oc -n openshift-monitoring edit configmap cluster-monitoring-config |
| 42 | +---- |
| 43 | + |
| 44 | +.. Add your configuration under `data/config.yaml` as a key-value pair `<component_name>:{nbsp}<component_configuration>`: |
| 45 | ++ |
| 46 | +[source,yaml] |
| 47 | +---- |
| 48 | +apiVersion: v1 |
| 49 | +kind: ConfigMap |
| 50 | +metadata: |
| 51 | + name: cluster-monitoring-config |
| 52 | + namespace: openshift-monitoring |
| 53 | +data: |
| 54 | + config.yaml: | |
| 55 | + <component>: |
| 56 | + <configuration_for_the_component> |
| 57 | +---- |
| 58 | ++ |
| 59 | +Substitute `<component>` and `<configuration_for_the_component>` accordingly. |
| 60 | ++ |
| 61 | +The following example `ConfigMap` object configures a persistent volume claim (PVC) for Prometheus. This relates to the Prometheus instance that monitors core {product-title} components only: |
| 62 | ++ |
| 63 | +[source,yaml] |
| 64 | +---- |
| 65 | +apiVersion: v1 |
| 66 | +kind: ConfigMap |
| 67 | +metadata: |
| 68 | + name: cluster-monitoring-config |
| 69 | + namespace: openshift-monitoring |
| 70 | +data: |
| 71 | + config.yaml: | |
| 72 | + prometheusK8s: <1> |
| 73 | + volumeClaimTemplate: |
| 74 | + spec: |
| 75 | + storageClassName: fast |
| 76 | + volumeMode: Filesystem |
| 77 | + resources: |
| 78 | + requests: |
| 79 | + storage: 40Gi |
| 80 | +---- |
| 81 | +<1> Defines the Prometheus component and the subsequent lines define its configuration. |
| 82 | + |
| 83 | +** *To configure components that monitor user-defined projects*: |
| 84 | +endif::openshift-dedicated,openshift-rosa[] |
| 85 | +.. Edit the `user-workload-monitoring-config` `ConfigMap` object in the `openshift-user-workload-monitoring` project: |
| 86 | ++ |
| 87 | +[source,terminal] |
| 88 | +---- |
| 89 | +$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config |
| 90 | +---- |
| 91 | + |
| 92 | +.. Add your configuration under `data/config.yaml` as a key-value pair `<component_name>:{nbsp}<component_configuration>`: |
| 93 | ++ |
| 94 | +[source,yaml] |
| 95 | +---- |
| 96 | +apiVersion: v1 |
| 97 | +kind: ConfigMap |
| 98 | +metadata: |
| 99 | + name: user-workload-monitoring-config |
| 100 | + namespace: openshift-user-workload-monitoring |
| 101 | +data: |
| 102 | + config.yaml: | |
| 103 | + <component>: |
| 104 | + <configuration_for_the_component> |
| 105 | +---- |
| 106 | ++ |
| 107 | +Substitute `<component>` and `<configuration_for_the_component>` accordingly. |
| 108 | ++ |
| 109 | +The following example `ConfigMap` object configures a data retention period and minimum container resource requests for Prometheus. This relates to the Prometheus instance that monitors user-defined projects only: |
| 110 | ++ |
| 111 | +[source,yaml] |
| 112 | +---- |
| 113 | +apiVersion: v1 |
| 114 | +kind: ConfigMap |
| 115 | +metadata: |
| 116 | + name: user-workload-monitoring-config |
| 117 | + namespace: openshift-user-workload-monitoring |
| 118 | +data: |
| 119 | + config.yaml: | |
| 120 | + prometheus: <1> |
| 121 | + retention: 24h <2> |
| 122 | + resources: |
| 123 | + requests: |
| 124 | + cpu: 200m <3> |
| 125 | + memory: 2Gi <4> |
| 126 | +---- |
| 127 | +<1> Defines the Prometheus component and the subsequent lines define its configuration. |
| 128 | +<2> Configures a twenty-four hour data retention period for the Prometheus instance that monitors user-defined projects. |
| 129 | +<3> Defines a minimum resource request of 200 millicores for the Prometheus container. |
| 130 | +<4> Defines a minimum pod resource request of 2 GiB of memory for the Prometheus container. |
| 131 | +ifndef::openshift-dedicated,openshift-rosa[] |
| 132 | ++ |
| 133 | +[NOTE] |
| 134 | +==== |
| 135 | +The Prometheus config map component is called `prometheusK8s` in the `cluster-monitoring-config` `ConfigMap` object and `prometheus` in the `user-workload-monitoring-config` `ConfigMap` object. |
| 136 | +==== |
| 137 | +endif::openshift-dedicated,openshift-rosa[] |
| 138 | + |
| 139 | +. Save the file to apply the changes to the `ConfigMap` object. |
| 140 | ++ |
| 141 | +[WARNING] |
| 142 | +==== |
| 143 | +Different configuration changes to the `ConfigMap` object result in different outcomes: |
| 144 | + |
| 145 | +* The pods are not redeployed. Therefore, there is no service outage. |
| 146 | +
|
| 147 | +* The affected pods are redeployed: |
| 148 | +
|
| 149 | +** For single-node clusters, this results in temporary service outage. |
| 150 | + |
| 151 | +** For multi-node clusters, because of high-availability, the affected pods are gradually rolled out and the monitoring stack remains available. |
| 152 | + |
| 153 | +** Configuring and resizing a persistent volume always results in a service outage, regardless of high availability. |
| 154 | + |
| 155 | +Each procedure that requires a change in the config map includes its expected outcome. |
| 156 | +==== |
0 commit comments