注意
本文档适用于 Ceph 的开发版本。
性能计数器
性能计数器为量表(gauges)和计数器(counters)提供了通用的内部基础架构。计数的值可以是整数,也可以是浮点数。还有一种“平均值”(average)类型(通常为浮点数),它结合了总和(sum)计数器和数量(num)计数器,可以相除以提供平均值。
目的是通过 collectd 或 statsd 等工具收集和聚合此数据,并将其馈送到 graphite 等工具中进行绘图和分析。另外,请注意 Prometheus 模块和 Telemetry 模块。
用户和开发人员也可以本地访问性能计数器数据,以检查集群的整体运行状况、识别工作负载模式、按守护程序类型监控集群性能,以及对延迟、限流、内存管理等问题进行故障排除(请参阅 访问)。
访问
性能计数器数据通过管理套接字访问。例如:
ceph daemon osd.0 perf schema
ceph daemon osd.0 perf dump
集合
值被分组到命名集合中,通常代表一个子系统或一个子系统的实例。例如,内部的 throttle 机制会报告其限流情况的统计信息,每个实例的命名方式如下:
throttle-msgr_dispatch_throttler-hbserver
throttle-msgr_dispatch_throttler-client
throttle-filestore_bytes
...
模式
perf schema 命令会转储一个 JSON 描述,说明哪些值可用以及它们的类型。每个命名值都有一个 type 位域,定义了以下位:
位 |
含义 |
|---|---|
1 |
浮点值 |
2 |
无符号 64 位整数值 |
4 |
平均值(总和 + 计数对),其中 |
8 |
计数器(与量表相对) |
每个值都将设置位 1 或位 2 来指示类型(浮点数或整数)。
如果设置了位 8(计数器),则该值是单调递增的,读取器可能希望减去先前读取的值以获取前一时间间隔内的增量。
如果设置了位 4(平均值),则会有两个值可供读取,一个总和和一个计数。如果它是一个计数器,则前一时间间隔的平均值将是总和增量(自上次读取以来的变化)除以计数增量。或者,直接将值相除将提供生命周期平均值。通常这些用于测量延迟(请求数量和请求延迟的总和),而前一时间间隔的平均值是令人感兴趣的。
不必解释位域,metric type 具有 gauge 或 counter 中的一个值,value type 属性将是 real、integer、real-integer-pair(用于总和 + 实际计数对)或 integer-integer-pair(用于总和 + 整数计数对)之一。
这是一个模式输出的示例:
{
"throttle-bluestore_throttle_bytes": {
"val": {
"type": 2,
"metric_type": "gauge",
"value_type": "integer",
"description": "Currently available throttle",
"nick": ""
},
"max": {
"type": 2,
"metric_type": "gauge",
"value_type": "integer",
"description": "Max value for throttle",
"nick": ""
},
"get_started": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Number of get calls, increased before wait",
"nick": ""
},
"get": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Gets",
"nick": ""
},
"get_sum": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Got data",
"nick": ""
},
"get_or_fail_fail": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Get blocked during get_or_fail",
"nick": ""
},
"get_or_fail_success": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Successful get during get_or_fail",
"nick": ""
},
"take": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Takes",
"nick": ""
},
"take_sum": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Taken data",
"nick": ""
},
"put": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Puts",
"nick": ""
},
"put_sum": {
"type": 10,
"metric_type": "counter",
"value_type": "integer",
"description": "Put data",
"nick": ""
},
"wait": {
"type": 5,
"metric_type": "gauge",
"value_type": "real-integer-pair",
"description": "Waiting latency",
"nick": ""
}
}
转储
实际转储与模式类似,只是平均值被分组。例如:
{
"throttle-msgr_dispatch_throttler-hbserver" : {
"get_or_fail_fail" : 0,
"get_sum" : 0,
"max" : 104857600,
"put" : 0,
"val" : 0,
"take" : 0,
"get_or_fail_success" : 0,
"wait" : {
"avgcount" : 0,
"sum" : 0
},
"get" : 0,
"take_sum" : 0,
"put_sum" : 0
},
"throttle-msgr_dispatch_throttler-client" : {
"get_or_fail_fail" : 0,
"get_sum" : 82760,
"max" : 104857600,
"put" : 2637,
"val" : 0,
"take" : 0,
"get_or_fail_success" : 0,
"wait" : {
"avgcount" : 0,
"sum" : 0
},
"get" : 2637,
"take_sum" : 0,
"put_sum" : 82760
}
}
带标签的性能计数器
注意
带标签的性能计数器是在 Ceph 的 Reef 版本中引入的。
Ceph 守护程序能够发射一组具有不同标签的性能计数器实例。这些计数器旨在用于在 Prometheus 和 Grafana 等第三方工具中可视化特定指标。
例如,下面的计数器显示了不同用户在不同存储桶上的 put 请求数量:
{
"rgw": [
{
"labels": {
"Bucket: "bkt1",
"User: "user1",
},
"counters": {
"put": 1,
},
},
{
"labels": {},
"counters": {
"put": 4,
},
},
{
"labels": {
"Bucket: "bkt1",
"User: "user2",
},
"counters": {
"put": 3,
},
},
]
}
所有带标签和不带标签的性能计数器都可以通过 ceph daemon {daemon id} counter dump 命令查看。
所有带标签和不带标签的性能计数器的模式可以通过 ceph daemon {daemon id} counter schema 命令查看。
在上面的示例中,第二个没有标签的计数器是在 ceph daemon {daemon id} perf dump 中也会显示的计数器。
由于 counter dump 和 counter schema 命令可用于查看两种类型的计数器,因此不建议使用 perf dump 和 perf schema 命令,这两个命令保留是为了向后兼容,并且只继续发射不带标签的计数器。
一些通过 perf dump 和 perf schema 发射的性能计数器在未来版本中可能会变为带标签的,因此将不再分别由 perf dump 和 perf schema 发射。