第 9 章 监控在 RHOSO 上运行的集群


您可以为在 OpenShift (RHOSO) 上运行的 Red Hat OpenStack Services 的集群关联可观察性指标。通过从这两个环境收集指标,您可以监控基础架构和应用程序层中的问题并进行故障排除。

对于在 RHOSO 上运行的集群,有两种支持的指标关联方法:

  • 远程写入 外部 Prometheus 实例。
  • 从 OpenShift Container Platform 联邦端点收集数据到 RHOSO 可观察性堆栈。

9.1. 远程写入外部 Prometheus 实例

对 OpenShift (RHOSO) 和 OpenShift Container Platform 上的 Red Hat OpenStack Services 使用远程写入,将其指标推送到外部 Prometheus 实例。

先决条件

  • 您可以访问外部 Prometheus 实例。
  • 您有对 RHOSO 和集群的管理访问权限。
  • 您有用于与 mTLS 的安全通信的证书。
  • 您的 Prometheus 实例被配置为客户端 TLS 证书,并被设置为远程写入接收器。
  • Cluster Observability Operator 安装在 RHOSO 集群中。
  • RHOSO 集群的监控堆栈配置为收集您感兴趣的指标。
  • Telemetry 在 RHOSO 环境中被启用。

    注意

    要验证 telemetry 服务是否正常运行,请输入以下命令:

    $ oc -n openstack get monitoringstacks metric-storage -o yaml
    Copy to Clipboard Toggle word wrap

    monitoringstacks CRD 指示遥测是否已正确启用。

流程

  1. 配置 RHOSO 管理集群,将指标发送到 Prometheus:

    1. 输入以下命令在 openstack 命名空间中创建一个名为 mtls-bundle 的 secret,该 secret 包含 HTTPS 客户端证书以向 Prometheus 进行身份验证:

      $ oc --namespace openstack \
          create secret generic mtls-bundle \
              --from-file=./ca.crt \
              --from-file=osp-client.crt \
              --from-file=osp-client.key
      Copy to Clipboard Toggle word wrap
    2. 运行以下命令,打开 controlplane 配置进行编辑:

      $ oc -n openstack edit openstackcontrolplane/controlplane
      Copy to Clipboard Toggle word wrap
    3. 打开配置后,替换 .spec.telemetry.template.metricStorage 部分,以便 RHOSO 将指标发送到 Prometheus。例如:

            metricStorage:
              customMonitoringStack:
                alertmanagerConfig:
                  disabled: false
                logLevel: info
                prometheusConfig:
                  scrapeInterval: 30s
                  remoteWrite:
                  - url: https://external-prometheus.example.com/api/v1/write 
      1
      
                    tlsConfig:
                      ca:
                        secret:
                          name: mtls-bundle
                          key: ca.crt
                      cert:
                        secret:
                          name: mtls-bundle
                          key: ocp-client.crt
                      keySecret:
                        name: mtls-bundle
                        key: ocp-client.key
                  replicas: 2
                resourceSelector:
                  matchLabels:
                    service: metricStorage
                resources:
                  limits:
                    cpu: 500m
                    memory: 512Mi
                  requests:
                    cpu: 100m
                    memory: 256Mi
                retention: 1d 
      2
      
              dashboardsEnabled: false
              dataplaneNetwork: ctlplane
              enabled: true
              prometheusTls: {}
      Copy to Clipboard Toggle word wrap
      1
      将此 URL 替换为 Prometheus 实例的 URL。
      2
      设置保留周期。另外,因为外部收集,您可以减少本地指标的保留。
  2. 配置运行工作负载的租户集群,将指标发送到 Prometheus:

    1. 以 YAML 文件形式创建集群监控配置映射。映射必须包含远程写入配置和集群标识符。例如:

      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: cluster-monitoring-config
        namespace: openshift-monitoring
      data:
        config.yaml: |
          prometheusK8s:
            retention: 1d 
      1
      
            remoteWrite:
            - url: "https://external-prometheus.example.com/api/v1/write"
              writeRelabelConfigs:
              - sourceLabels:
                - __tmp_openshift_cluster_id__
                targetLabel: cluster_id
                action: replace
              tlsConfig:
                ca:
                  secret:
                    name: mtls-bundle
                    key: ca.crt
                cert:
                  secret:
                    name: mtls-bundle
                    key: ocp-client.crt
                keySecret:
                  name: mtls-bundle
                  key: ocp-client.key
      Copy to Clipboard Toggle word wrap
      1
      设置保留周期。另外,因为外部收集,您可以减少本地指标的保留。
    2. 将配置映射保存为名为 cluster-monitoring-config.yaml 的文件。
    3. 输入以下命令在 openshift-monitoring 命名空间中创建一个名为 mtls-bundle 的 secret,其中包含用于向 Prometheus 进行身份验证的 HTTPS 客户端证书:

      $ oc --namespace openshift-monitoring \
          create secret generic mtls-bundle \
              --from-file=./ca.crt \
              --from-file=ocp-client.crt \
              --from-file=ocp-client.key
      Copy to Clipboard Toggle word wrap
    4. 运行以下命令来应用集群监控配置:

      $ oc apply -f cluster-monitoring-config.yaml
      Copy to Clipboard Toggle word wrap

传播更改后,您可以在外部 Prometheus 实例中看到聚合的指标。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat