基础设施指标
RobustMQ 提供了全面的基础设施监控指标,帮助运维人员监控系统的健康状态、性能表现和资源使用情况。所有指标都基于 Prometheus 格式,可以通过 /metrics
端点获取。
网络层指标 (Network)
请求处理指标
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
request_total_ms | Histogram | request_type , network | 请求处理总耗时(毫秒) |
request_queue_ms | Histogram | request_type , network | 请求在队列中的等待时间(毫秒) |
request_handler_ms | Histogram | request_type , network | 请求处理器执行时间(毫秒) |
request_response_ms | Histogram | request_type , network | 响应处理时间(毫秒) |
request_response_queue_ms | Histogram | request_type , network | 响应队列等待时间(毫秒) |
连接和队列指标
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
broker_connections_max | Gauge | - | Broker 最大连接数限制 |
broker_network_queue_num | Gauge | queue_type | 网络队列中的消息数量 |
broker_active_thread_num | Gauge | thread_type | 活跃线程数量 |
标签说明:
request_type
: 请求类型(如 mqtt, grpc, http)network
: 网络类型(tcp, websocket, quic)queue_type
: 队列类型(accept, handler, response)thread_type
: 线程类型(accept, handler, response)
gRPC 服务指标
请求统计
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
grpc_requests_total | Counter | method , service | gRPC 请求总数 |
grpc_request_errors_total | Counter | method , service , error_code | gRPC 请求错误总数 |
性能指标
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
grpc_request_duration_milliseconds | Histogram | method , service | gRPC 请求耗时(毫秒) |
grpc_request_size_bytes | Histogram | method , service | gRPC 请求大小(字节) |
grpc_response_size_bytes | Histogram | method , service | gRPC 响应大小(字节) |
标签说明:
method
: gRPC 方法名service
: gRPC 服务名error_code
: 错误代码
HTTP 服务指标
请求统计
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
http_requests_total | Counter | method , path , status_code | HTTP 请求总数 |
http_request_errors_total | Counter | method , path , error_type | HTTP 请求错误总数 |
性能指标
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
http_request_duration_milliseconds | Histogram | method , path | HTTP 请求耗时(毫秒) |
http_request_size_bytes | Histogram | method , path | HTTP 请求大小(字节) |
http_response_size_bytes | Histogram | method , path | HTTP 响应大小(字节) |
标签说明:
method
: HTTP 方法(GET, POST, PUT, DELETE)path
: 请求路径status_code
: HTTP 状态码error_type
: 错误类型
存储层指标 (RocksDB)
操作统计
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
rocksdb_operation_count | Counter | source , operation | RocksDB 操作次数 |
rocksdb_operation_ms | Histogram | source , operation | RocksDB 操作耗时(毫秒) |
标签说明:
source
: 数据源(如 metadata, session, message)operation
: 操作类型(save, get, delete, list)
常见操作类型
- save: 数据写入操作
- get: 数据读取操作
- delete: 数据删除操作
- list: 数据列表查询操作
Broker 核心指标
系统状态
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
broker_status | Gauge | node_id | Broker 节点状态(1=运行,0=停止) |
broker_uptime_seconds | Counter | node_id | Broker 运行时间(秒) |
资源使用
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
broker_memory_usage_bytes | Gauge | node_id , type | 内存使用量(字节) |
broker_cpu_usage_percent | Gauge | node_id | CPU 使用率(百分比) |
broker_disk_usage_bytes | Gauge | node_id , path | 磁盘使用量(字节) |
标签说明:
node_id
: 节点标识type
: 内存类型(heap, non_heap, total)path
: 磁盘路径
元数据服务指标 (Meta Service)
集群状态
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
meta_cluster_nodes_total | Gauge | cluster_id | 集群节点总数 |
meta_cluster_nodes_active | Gauge | cluster_id | 集群活跃节点数 |
meta_leader_elections_total | Counter | cluster_id | 领导者选举次数 |
数据同步
指标名称 | 类型 | 标签 | 描述 |
---|---|---|---|
meta_sync_operations_total | Counter | operation_type | 元数据同步操作次数 |
meta_sync_latency_ms | Histogram | operation_type | 元数据同步延迟(毫秒) |
使用示例
Prometheus 配置
yaml
scrape_configs:
- job_name: 'robustmq'
static_configs:
- targets: ['localhost:9090']
metrics_path: '/metrics'
scrape_interval: 15s
Grafana 查询示例
text
# 平均请求处理时间
rate(request_total_ms_sum[5m]) / rate(request_total_ms_count[5m])
# gRPC 错误率
rate(grpc_request_errors_total[5m]) / rate(grpc_requests_total[5m]) * 100
# RocksDB 操作 QPS
rate(rocksdb_operation_count[5m])
# 网络队列积压
broker_network_queue_num
告警规则示例
yaml
groups:
- name: robustmq_infrastructure
rules:
- alert: HighRequestLatency
expr: histogram_quantile(0.95, rate(request_total_ms_bucket[5m])) > 1000
for: 2m
labels:
severity: warning
annotations:
summary: "请求延迟过高"
description: "95% 的请求延迟超过 1 秒"
- alert: HighErrorRate
expr: rate(grpc_request_errors_total[5m]) / rate(grpc_requests_total[5m]) > 0.05
for: 1m
labels:
severity: critical
annotations:
summary: "gRPC 错误率过高"
description: "gRPC 错误率超过 5%"
- alert: RocksDBSlowOperations
expr: histogram_quantile(0.95, rate(rocksdb_operation_ms_bucket[5m])) > 100
for: 3m
labels:
severity: warning
annotations:
summary: "RocksDB 操作缓慢"
description: "95% 的 RocksDB 操作耗时超过 100ms"
通过这些基础设施指标,运维团队可以全面了解 RobustMQ 系统的运行状态,及时发现和解决性能问题,确保系统的稳定运行。