Ceph 监控中应用 Prometheus relabel 功能

本文涉及的产品
可观测可视化 Grafana 版,10个用户账号 1个月
EMR Serverless StarRocks,5000CU*H 48000GB*H
可观测监控 Prometheus 版,每月50GB免费额度
简介: 1. 问题描述工作环境中有三个独立的 Ceph 集群,分别负责对象存储、块存储和文件存储。搭建这几个 Ceph 集群时,我对 Ceph 重命名 Cluster name 的难度没有足够的了解,所以使用的都是默认的 cluster name:ceph,不巧的是 Prometheus 的 ceph_exporter 就是用 cluster name 来区分不同集群,结果是 Grafana 中各个集群的数据无法区分,所有的集群数据都绘制在了一个图标中,非常乱不说,而且部分数据还无法正常显示。

relabel

1. 问题描述

工作环境中有三个独立的 Ceph 集群,分别负责对象存储、块存储和文件存储。搭建这几个 Ceph 集群时,我对 Ceph 重命名 Cluster name 的难度没有足够的了解,所以使用的都是默认的 cluster name:ceph,不巧的是 Prometheus 的 ceph_exporter 就是用 cluster name 来区分不同集群,结果是 Grafana 中各个集群的数据无法区分,所有的集群数据都绘制在了一个图标中,非常乱不说,而且部分数据还无法正常显示。

也许大家会说,那就改 Ceph cluster name 不就好了。问题是 Ceph 修改 Cluster name 没那么简单,ceph 文件存储目录都是和 Cluster name 有对应关系的,所以很多配置文件和数据都需要修改目录才能生效,对于已经开始正式使用的 Ceph 集群,这么做风险有点大。当然如果给每个 Ceph 集群单独搭建一个 Prometheus 和 Grafana 环境的话,问题也能解决,但这种方式显得太没技术含量了,不到万不得已,实在不想采用。

我最开始想到的解决方式是修改 ceph_exporter,既然 cluster name 不行,那加上 Ceph 的 fsid 总能区分出来了吧,就像这样:

image.png

不过 fsid 这个变量很难直观看出来代表的是哪个 Ceph 集群,也不是一个好的方案。

最后多亏 neurodrone,才了解到 Prometheus 的 relabel 功能,可以完美的解决这个问题。

2. relabel 配置

Relabel 的本意其实修改导出 metrics 信息的 label 字段,可以对 metrics 做过滤,删除某些不必要的 metrics,label 重命名等,而且也支持对 label 的值作出修改。

举一个例子,三个集群的 ceph_pool_write_total 的 label cluster 取值都为 ceph。但在 Prometheus 的配置中,他们分别是分属于不通 job 的,我们可以通过对 job 进行 relabel 来修改 cluster label 的指,来完成区分。

# cluster1's metric
ceph_pool_write_total{cluster="ceph",pool=".rgw.root"} 4

# cluster2's metric
ceph_pool_write_total{cluster="ceph",pool=".rgw.root"} 10

# cluster3's metric
ceph_pool_write_total{cluster="ceph",pool=".rgw.root"} 7

具体的配置如下,cluster label 的值就改为了 ceph*,并且导出到了新 label clusters 中。

scrape_configs:
  - job_name: 'ceph1'
    relabel_configs:
    - source_labels: ["cluster"]
      replacement: "ceph1"
      action: replace
      target_label: "clusters"
    static_configs:
    - targets: ['ceph1:9128']
      labels:
        alias: ceph1

  - job_name: 'ceph2'
    relabel_configs:
    - source_labels: ["cluster"]
      replacement: "ceph2"
      action: replace
      target_label: "clusters"
    static_configs:
    - targets: ['ceph2:9128']
      labels:
        alias: ceph2

  - job_name: 'ceph3'
    relabel_configs:
    - source_labels: ["cluster"]
      replacement: "ceph3"
      action: replace
      target_label: "clusters"
    static_configs:
    - targets: ['ceph3:9128']
      labels:
        alias: ceph3

修改后的 metric 信息变成这个样子,这样我们就可以区分出不同的 Ceph 集群的数据了。

# cluster1's metric
ceph_pool_write_total{clusters="ceph1",pool=".rgw.root"} 4

# cluster2's metric
ceph_pool_write_total{clusters="ceph2",pool=".rgw.root"} 10

# cluster3's metric
ceph_pool_write_total{clusters="ceph3",pool=".rgw.root"} 7

3. Grafana dashboard 调整

光是修改 Prometheus 的配置还不够,毕竟我们还要在界面上能体现出来,Grafana 的 dashboard 也要做对应的修改,本文使用的 dashboard 是 Ceph - Cluster

首先是要 dashboard 添加 clusters 变量,在界面上操作即可。
先点击 dashboard 的 "settings" 按钮(显示齿轮图标的就是)

image.png

如下图所示添加 clusters variable,最后保存。

image.png

我们已经可以在 dashboard 上看到新加的 variable 了:

image.png

接下来每个图表的查询语句也要做对应的修改:

image.png

最终改好的 dashboard json 文件可从如下链接下载到:
ceph-cluster.json

4. 参考文档

相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
目录
相关文章
|
22天前
|
Prometheus 监控 Cloud Native
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
|
13天前
|
Prometheus 监控 Kubernetes
Prometheus 在微服务架构中的应用
【8月更文第29天】随着微服务架构的普及,监控和跟踪各个服务的状态变得尤为重要。Prometheus 是一个开源的监控系统和时间序列数据库,非常适合用于微服务架构中的监控。本文将详细介绍 Prometheus 如何支持微服务架构下的监控需求,包括服务发现、服务间的监控指标收集以及如何配置 Prometheus 来适应这些需求。
40 0
|
8天前
|
Prometheus 监控 Cloud Native
prometheus监控ceph集群环境
文章介绍了如何使用Prometheus监控Ceph集群环境,包括启用Prometheus模块、验证模块启用成功、访问Ceph的exporter、修改Prometheus配置文件、热加载配置,以及Grafana采集数据的方法。同时,还涵盖了监控Ceph集群宿主机的步骤,如在所有节点安装node-exporter、修改Prometheus配置文件、热加载配置,以及Grafana采集数据。
26 6
|
7天前
|
Prometheus 监控 Cloud Native
Ceph Reef(18.2.X)的内置Prometheus监控集群
这篇文章是关于Ceph Reef(18.2.X)版本中内置Prometheus监控集群的使用方法,包括如何查看集群架构、访问Prometheus、Grafana、Node-Exporter和Alertmanager的Web界面,以及推荐阅读的自实现Prometheus监控资源链接。
30 2
|
13天前
|
存储 Prometheus 监控
Grafana 与 Prometheus 集成:打造高效监控系统
【8月更文第29天】在现代软件开发和运维领域,监控系统已成为不可或缺的一部分。Prometheus 和 Grafana 作为两个非常流行且互补的开源工具,可以协同工作来构建强大的实时监控解决方案。Prometheus 负责收集和存储时间序列数据,而 Grafana 则提供直观的数据可视化功能。本文将详细介绍如何集成这两个工具,构建一个高效、灵活的监控系统。
50 1
|
14天前
|
Prometheus 监控 Cloud Native
Spring Boot 性能护航!Prometheus、Grafana、ELK 组合拳,点燃数字化时代应用稳定之火
【8月更文挑战第29天】在现代软件开发中,保证应用性能与稳定至关重要。Spring Boot 作为流行的 Java 框架,结合 Prometheus、Grafana 和 ELK 可显著提升监控与分析能力。Prometheus 负责收集时间序列数据,Grafana 将数据可视化,而 ELK (Elasticsearch、Logstash、Kibana)则管理并分析应用日志。通过具体实例演示了如何在 Spring Boot 应用中集成这些工具:配置 Prometheus 获取度量信息、Grafana 显示结果及 ELK 分析日志,从而帮助开发者快速定位问题,确保应用稳定高效运行。
30 1
|
16天前
|
Prometheus 监控 Cloud Native
使用Prometheus搞定微服务监控
使用Prometheus搞定微服务监控
使用Prometheus搞定微服务监控
|
29天前
|
Prometheus Kubernetes 监控
Kubernetes(K8S) 监控 Prometheus + Grafana
Kubernetes(K8S) 监控 Prometheus + Grafana
104 2
|
1月前
|
Prometheus 监控 Cloud Native
在 HBase 集群中,Prometheus 通常监控哪些类型的性能指标?
在 HBase 集群中,Prometheus 通常监控哪些类型的性能指标?
|
16天前
|
Prometheus 监控 Cloud Native
基于prometheus的微服务指标监控
基于prometheus的微服务指标监控