|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * observability/monitoring/shiftstack-prometheus-configuration.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="monitoring-configuring-shiftstack-remotewrite_{context}"] |
| 7 | += Remote writing to an external Prometheus instance |
| 8 | + |
| 9 | +Use remote write with both {rhoso-first} and {product-title} to push their metrics to an external Prometheus instance. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +- You have access to an external Prometheus instance. |
| 14 | +- You have administrative access to {rhoso} and your cluster. |
| 15 | +- You have certificates for secure communication with mTLS. |
| 16 | +- Your Prometheus instance is configured for client TLS certificates and has been set up as a remote write receiver. |
| 17 | +- The Cluster Observability Operator is installed on your {rhoso} cluster. |
| 18 | +- The monitoring stack for your {rhoso} cluster is configured to collect the metrics that you are interested in. |
| 19 | +- Telemetry is enabled in the {rhoso} environment. |
| 20 | ++ |
| 21 | +[NOTE] |
| 22 | +==== |
| 23 | +To verify that the telemetry service is operating normally, entering the following command: |
| 24 | +[source,shell] |
| 25 | +---- |
| 26 | +$ oc -n openstack get monitoringstacks metric-storage -o yaml |
| 27 | +---- |
| 28 | +The `monitoringstacks` CRD indicates whether telemetry is enabled correctly. |
| 29 | +==== |
| 30 | +
|
| 31 | +.Procedure |
| 32 | + |
| 33 | +// Steps 1, 2, 3, and 4 run on the OpenShift cluster hosting the RHOSO control plane. This configure RHOSO to send their metrics to an external prometheus. |
| 34 | +// |
| 35 | +// Steps 5, 6, 7, and 8 run on the tenant's OpenShift cluster. This configures the tenant OpenShift cluster to send their metrics to the same Prometheus instance. |
| 36 | +// Comment from before moving telemetry check to prereqs -- offset by 1. |
| 37 | + |
| 38 | +// on mgmt cluster |
| 39 | + |
| 40 | +. Configure your {rhoso} management cluster to send metrics to Prometheus: |
| 41 | + |
| 42 | +.. Create a secret that is named `mtls-bundle` in the `openstack` namespace that contains HTTPS client certificates for authentication to Prometheus by entering the following command: |
| 43 | ++ |
| 44 | +[source,shell] |
| 45 | +---- |
| 46 | +$ oc --namespace openstack \ |
| 47 | + create secret generic mtls-bundle \ |
| 48 | + --from-file=./ca.crt \ |
| 49 | + --from-file=osp-client.crt \ |
| 50 | + --from-file=osp-client.key |
| 51 | +---- |
| 52 | + |
| 53 | +.. Open the `controlplane` configuration for editing by running the following command: |
| 54 | ++ |
| 55 | +[source,shell] |
| 56 | +---- |
| 57 | +$ oc -n openstack edit openstackcontrolplane/controlplane |
| 58 | +---- |
| 59 | + |
| 60 | +.. With the configuration open, replace the `.spec.telemetry.template.metricStorage` section so that {rhoso} sends metrics to Prometheus. As an example: |
| 61 | ++ |
| 62 | +[source,yaml] |
| 63 | +---- |
| 64 | + metricStorage: |
| 65 | + customMonitoringStack: |
| 66 | + alertmanagerConfig: |
| 67 | + disabled: false |
| 68 | + logLevel: info |
| 69 | + prometheusConfig: |
| 70 | + scrapeInterval: 30s |
| 71 | + remoteWrite: |
| 72 | + - url: https://external-prometheus.example.com/api/v1/write # <1> |
| 73 | + tlsConfig: |
| 74 | + ca: |
| 75 | + secret: |
| 76 | + name: mtls-bundle |
| 77 | + key: ca.crt |
| 78 | + cert: |
| 79 | + secret: |
| 80 | + name: mtls-bundle |
| 81 | + key: ocp-client.crt |
| 82 | + keySecret: |
| 83 | + name: mtls-bundle |
| 84 | + key: ocp-client.key |
| 85 | + replicas: 2 |
| 86 | + resourceSelector: |
| 87 | + matchLabels: |
| 88 | + service: metricStorage |
| 89 | + resources: |
| 90 | + limits: |
| 91 | + cpu: 500m |
| 92 | + memory: 512Mi |
| 93 | + requests: |
| 94 | + cpu: 100m |
| 95 | + memory: 256Mi |
| 96 | + retention: 1d # <2> |
| 97 | + dashboardsEnabled: false |
| 98 | + dataplaneNetwork: ctlplane |
| 99 | + enabled: true |
| 100 | + prometheusTls: {} |
| 101 | +---- |
| 102 | +<1> Replace this URL with the URL of your Prometheus instance. |
| 103 | +<2> Set a retention period. Optionally, you can reduce retention for local metrics because of external collection. |
| 104 | +// run on tenant's openshift cluster |
| 105 | +. Configure the tenant cluster on which your workloads run to send metrics to Prometheus: |
| 106 | + |
| 107 | +.. Create a cluster monitoring config map as a YAML file. The map must include a remote write configuration and cluster identifiers. As an example: |
| 108 | ++ |
| 109 | +[source,yaml] |
| 110 | +---- |
| 111 | +apiVersion: v1 |
| 112 | +kind: ConfigMap |
| 113 | +metadata: |
| 114 | + name: cluster-monitoring-config |
| 115 | + namespace: openshift-monitoring |
| 116 | +data: |
| 117 | + config.yaml: | |
| 118 | + prometheusK8s: |
| 119 | + retention: 1d # <1> |
| 120 | + remoteWrite: |
| 121 | + - url: "https://external-prometheus.example.com/api/v1/write" |
| 122 | + writeRelabelConfigs: |
| 123 | + - sourceLabels: |
| 124 | + - __tmp_openshift_cluster_id__ |
| 125 | + targetLabel: cluster_id |
| 126 | + action: replace |
| 127 | + tlsConfig: |
| 128 | + ca: |
| 129 | + secret: |
| 130 | + name: mtls-bundle |
| 131 | + key: ca.crt |
| 132 | + cert: |
| 133 | + secret: |
| 134 | + name: mtls-bundle |
| 135 | + key: ocp-client.crt |
| 136 | + keySecret: |
| 137 | + name: mtls-bundle |
| 138 | + key: ocp-client.key |
| 139 | +---- |
| 140 | +<1> Set a retention period. Optionally, you can reduce retention for local metrics because of external collection. |
| 141 | + |
| 142 | +.. Save the config map as a file called `cluster-monitoring-config.yaml`. |
| 143 | + |
| 144 | +.. Create a secret that is named `mtls-bundle` in the `openshift-monitoring` namespace that contains HTTPS client certificates for authentication to Prometheus by entering the following command: |
| 145 | ++ |
| 146 | +[source,terminal] |
| 147 | +---- |
| 148 | +$ oc --namespace openshift-monitoring \ |
| 149 | + create secret generic mtls-bundle \ |
| 150 | + --from-file=./ca.crt \ |
| 151 | + --from-file=ocp-client.crt \ |
| 152 | + --from-file=ocp-client.key |
| 153 | +---- |
| 154 | + |
| 155 | +.. Apply the cluster monitoring configuration by running the following command: |
| 156 | ++ |
| 157 | +[source,terminal] |
| 158 | +---- |
| 159 | +$ oc apply -f cluster-monitoring-config.yaml |
| 160 | +---- |
| 161 | + |
| 162 | +After the changes propagate, you can see aggregated metrics in your external Prometheus instance. |
0 commit comments