7.7. 管理 Prometheus 环境

要使用 Prometheus 监控 Ceph 存储集群,您可以配置和启用 Prometheus 导出器,以便可以收集与 Ceph 存储集群相关的元数据信息。

先决条件

  • 正在运行的 Red Hat Ceph Storage 3.1 或更高版本的集群。
  • 安装红帽 Ceph 存储仪表板.
  • Red Hat Ceph Storage 仪表板节点的 root 级别访问。

流程

  1. 打开并编辑 /etc/prometheus/prometheus.yml 文件。

    1. global 部分下,将 scrape_intervalevaluation_interval 选项设置为 15 秒。

      示例

      global:
        scrape_interval:     15s
        evaluation_interval: 15s

    2. scrape_configs 部分下,添加 honor_labels: true 选项,并为每个 ceph-mgr 节点编辑 目标实例 选项。

      示例

      scrape_configs:
        - job_name: 'node'
          honor_labels: true
          static_configs:
          - targets: [ 'node1.example.com:9100' ]
            labels:
              instance: "node1.example.com"
          - targets: ['node2.example.com:9100']
            labels:
              instance: "node2.example.com"

      注意

      使用 honor_labels 选项可让 Ceph 输出与 Ceph 存储集群中任何节点相关的正确标记数据。这样,Ceph 可以在不覆盖 Prometheus 的情况下导出正确的 实例 标签。

    3. 要添加新节点,只需以以下格式添加 目标实例 选项:

      示例

      - targets: [ 'new-node.example.com:9100' ]
        labels:
          instance: "new-node"

      注意

      instance 标签必须与 Ceph 的 OSD 元数据 实例 字段中显示的内容匹配,这是节点的短主机名。这有助于将 Ceph 统计数据与节点的统计相关联。

  2. 将 Ceph 目标添加到 /etc/prometheus/ceph_targets.yml 文件,格式为:

    示例

    [
        {
            "targets": [ "cephnode1.example.com:9283" ],
            "labels": {}
        }
    ]

  3. 启用 Prometheus 模块:

    [root@mon ~]# ceph mgr module enable prometheus