# 常用指标的查询表达式 本文介绍 OBAgent 常用指标的查询表达式。 > **注意**:在查询时,您必须将变量替换成待查询的具体信息。 需要替换的字段如下: - @LABELS,替换为具体 Label 的过滤条件。 - @INTERVAL,替换为计算周期。 - @GBLABELS,替换为聚合的 Label 名称。 | **指标** | **表达式** | **单位** | | --- | --- | --- | | 活跃 MEMStore 大小 | `sum(ob_sysstat{stat_id="130000",@LABELS}) by (@GBLABELS) / 1048576` | MB | | 当前活跃会话数 | `sum(ob_active_session_num{@LABELS}) by ([@GBLABELS)` | - | | 块缓存命中率 | `100 * 1 / (1 + sum(rate(ob_sysstat{stat_id="50009",@LABELS}[@INTERVAL])) by ([@GBLABELS) ](/GBLABELS)) / sum(rate(ob_sysstat{stat_id="50008",@LABELS}[@INTERVAL])) by (@GBLABELS))` | % | | 块缓存大小 | `sum(ob_cache_size_bytes{cache_name="user_block_cache",@LABELS}) by ([@GBLABELS) ](/GBLABELS)) / 1048576` | MB | | 每秒提交的事务日志大小 | `sum(rate(ob_sysstat{stat_id="80057",@LABELS}[@INTERVAL])) by ([@GBLABELS) ](/GBLABELS))`| byte | | 每次事务日志写盘平均耗时 | `sum(rate(ob_sysstat{stat_id="80041",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="80040",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | CPU 使用率 | `100 * (1 - sum(rate(node_cpu_seconds_total{mode="idle", @LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(node_cpu_seconds_total{@LABELS}[@INTERVAL])) by (@GBLABELS))` | % | | 磁盘分区已使用容量 | `sum(node_filesystem_size_bytes{@LABELS} - node_filesystem_avail_bytes{@LABELS}) by (@GBLABELS) / 1073741824` | GB | | 每秒读次数 | `avg(rate(node_disk_reads_completed_total{@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 每次读取数据量 | `avg(rate(node_disk_read_bytes_total{@LABELS}[@INTERVAL])) by (@GBLABELS) / 1048576` | MB | | SSStore 每秒读次数 | `sum(rate(ob_sysstat{stat_id="60000",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | SSStore 每次读取平均耗时 | `sum(rate(ob_sysstat{stat_id="60001",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="60000",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | SSStore 每秒读取数据量 | `sum(rate(ob_sysstat{stat_id="60002",@LABELS}[@INTERVAL])) by (@GBLABELS)` | byte | | 每秒读取平均耗时 | `1000000 * (avg(rate(node_disk_read_time_seconds_total{@LABELS}[@INTERVAL])) by (@GBLABELS)) / (avg(rate(node_disk_reads_completed_total{@LABELS}[@INTERVAL])) by (@GBLABELS))` | us | | 平均每次 IO 读取耗时 | `1000000 * (avg(rate(node_disk_read_time_seconds_total{@LABELS}[@INTERVAL])) by (@GBLABELS)) / (avg(rate(node_disk_reads_completed_total{@LABELS}[@INTERVAL])) by (@GBLABELS))` | us | | 每秒写次数 | `avg(rate(node_disk_writes_completed_total{@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 每次写入数据量 | `avg(rate(node_disk_written_bytes_total{@LABELS}[@INTERVAL])) by (@GBLABELS) / 1048576` | MB | | SSStore 每秒写次数 | `sum(rate(ob_sysstat{stat_id="60003",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | SSStore 每次写入平均耗时 | `sum(rate(ob_sysstat{stat_id="60004",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="60003",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | SSStore 每秒写入数据量 | `sum(rate(ob_sysstat{stat_id="60005",@LABELS}[@INTERVAL])) by (@GBLABELS)` | byte | | 每秒写入平均耗时 | `1000000 * (avg(rate(node_disk_write_time_seconds_total{@LABELS}[@INTERVAL])) by (@GBLABELS)) / (avg(rate(node_disk_writes_completed_total{@LABELS}[@INTERVAL])) by (@GBLABELS))` | us | | 平均每次 IO 写入耗时 | `1000000 * (avg(rate(node_disk_write_time_seconds_total{@LABELS}[@INTERVAL])) by (@GBLABELS)) / (avg(rate(node_disk_writes_completed_total{@LABELS}[@INTERVAL])) by (@GBLABELS))` | us | | 过去 1 分钟系统平均负载 |`avg(node_load1{@LABELS}) by (@GBLABELS)`| - | | 过去 15 分钟系统平均负载 | `avg(node_load15{@LABELS}) by (@GBLABELS)` | - | | 过去 5 分钟系统平均负载 | `avg(node_load5{@LABELS}) by (@GBLABELS)` | - | | 触发合并阈值 | `sum(ob_sysstat{stat_id="130002",@LABELS}) by (@GBLABELS) / 1048576` | MB | | 内核 Buffer Cache 大小 | `avg(node_memory_Buffers_bytes{@LABELS}) by (@GBLABELS) / 1073741824` | GB | | 可用物理内存大小 | `avg(node_memory_MemFree_bytes{@LABELS}) by (@GBLABELS) / 1073741824` | GB | | 使用物理内存大小 | `(avg(node_memory_MemTotal_bytes{@LABELS}) by (@GBLABELS)`
`avg(node_memory_MemFree_bytes{@LABELS}) by (@GBLABELS)`
`avg(node_memory_Cached_bytes{@LABELS}) by (@GBLABELS)`
`avg(node_memory_Buffers_bytes{@LABELS}) by (@GBLABELS)) / 1073741824` | GB | | MEMStore 的上限 | `sum(ob_sysstat{stat_id="130004",@LABELS}) by (@GBLABELS) / 1048576` | MB | | MEMStore 使用百分比 | `100 * sum(ob_sysstat{stat_id="130001",@LABELS}) by (@GBLABELS) / sum(ob_sysstat{stat_id="130004",@LABELS}) by (@GBLABELS)` | % | | 写锁等待失败次数 | `sum(rate(ob_sysstat{stat_id="60022",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 写锁等待成功次数 | `sum(rate(ob_sysstat{stat_id="60021",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 写锁平均等待耗时 | `sum(rate(ob_sysstat{stat_id="60023",@LABELS}[@INTERVAL])) by (@GBLABELS) / (sum(rate(ob_sysstat{stat_id="60021",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="60022",@LABELS}[@INTERVAL])) by (@GBLABELS))` | us | | 每秒接收数据量 | `avg(rate(node_network_receive_bytes_total{@LABELS}[@INTERVAL])) by (@GBLABELS) / 1048576` | MB | | 每秒发送数据量 | `avg(rate(node_network_transmit_bytes_total{@LABELS}[@INTERVAL])) by (@GBLABELS) / 1048576` | MB | | CPU 使用率 | `100 * sum(ob_sysstat{stat_id="140006",@LABELS}) by (@GBLABELS) / sum(ob_sysstat{stat_id="140005",@LABELS}) by (@GBLABELS)` | % | | 分区数量 | `sum(ob_partition_num{@LABELS}) by (@GBLABELS)` | - | | 执行计划缓存命中率 | `100 * sum(rate(ob_plan_cache_hit_total{@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_plan_cache_access_total{@LABELS}[@INTERVAL])) by (@GBLABELS)` | % | | 执行计划缓存大小 | `sum(ob_plan_cache_memory_bytes{@LABELS}) by (@GBLABELS) / 1048576` | MB | | 平均每秒 SQL 进等待队列的次数 | `sum(rate(ob_sysstat{stat_id="20001",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | SQL 在等待队列中等待耗时 | `sum(rate(ob_sysstat{stat_id="20002",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="20001",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 行缓存命中率 | `100 * 1 / (1 + sum(rate(ob_sysstat{stat_id="50001",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="50000",@LABELS}[@INTERVAL])) by (@GBLABELS))` | % | | 缓存大小 | `sum(ob_cache_size_bytes{@LABELS}) by (@GBLABELS) / 1048576` | MB | | RPC 收包吞吐量 | `sum(rate(ob_sysstat{stat_id="10001",@LABELS}[@INTERVAL])) by (@GBLABELS)` | byte | | RPC 收包平均耗时 | `(sum(rate(ob_sysstat{stat_id="10005",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="10006",@LABELS}[@INTERVAL])) by (@GBLABELS)) / sum(rate(ob_sysstat{stat_id="10000",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | RPC 发包吞吐量 | `sum(rate(ob_sysstat{stat_id="10003",@LABELS}[@INTERVAL])) by (@GBLABELS)` | byte | | RPC 发包平均耗时 | `(sum(rate(ob_sysstat{stat_id="10005",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="10006",@LABELS}[@INTERVAL])) by (@GBLABELS)) / sum(rate(ob_sysstat{stat_id="10002",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒处理 SQL 语句数 | `sum(rate(ob_sysstat{stat_id="40002",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40004",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40006",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40008",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40000",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 服务端每条 SQL 语句平均处理耗时 | `(sum(rate(ob_sysstat{stat_id="40003",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40005",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40007",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40009",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40001",@LABELS}[@INTERVAL])) by (@GBLABELS)) /(sum(rate(ob_sysstat{stat_id="40002",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40004",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40006",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40008",@LABELS}[@INTERVAL])) by (@GBLABELS) + sum(rate(ob_sysstat{stat_id="40000",@LABELS}[@INTERVAL])) by (@GBLABELS))` | us | | 每秒处理 Delete 语句数 | `sum(rate(ob_sysstat{stat_id="40008",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 服务端每条 Delete 语句平均处理耗时 | `sum(rate(ob_sysstat{stat_id="40009",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="40008",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒处理分布式执行计划数 | `sum(rate(ob_sysstat{stat_id="40012",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 每秒处理 Insert 语句数 | `sum(rate(ob_sysstat{stat_id="40002",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 服务端每条 Insert 语句平均处理耗时 | `sum(rate(ob_sysstat{stat_id="40003",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="40002",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒处理本地执行数 | `sum(rate(ob_sysstat{stat_id="40010",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 每秒处理远程执行计划数 | `sum(rate(ob_sysstat{stat_id="40011",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 每秒处理 Replace 语句数 | `sum(rate(ob_sysstat{stat_id="40004",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 服务端每条 Replace 语句平均处理耗时 | `sum(rate(ob_sysstat{stat_id="40005",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="40004",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒处理 Select 语句数 | `sum(rate(ob_sysstat{stat_id="40000",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 服务端每条 Select 语句平均处理耗时 | `sum(rate(ob_sysstat{stat_id="40001",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="40000",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒处理 Update 语句数 | `sum(rate(ob_sysstat{stat_id="40006",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 服务端每条 Update 语句平均处理耗时 | `sum(rate(ob_sysstat{stat_id="40007",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="40006",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 表数量 | `max(ob_table_num{@LABELS}) by (@GBLABELS)` | - | | MEMStore 总大小 | `sum(ob_sysstat{stat_id="130001",@LABELS}) by (@GBLABELS) / 1048576` | MB | | 每秒处理事务数 | `sum(rate(ob_sysstat{stat_id="30005",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 服务端每个事务平均处理耗时 | `sum(rate(ob_sysstat{stat_id="30006",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="30005",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒提交的事务日志数 | `sum(rate(ob_sysstat{stat_id="30002",@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 每次事务日志网络同步平均耗时 | `sum(rate(ob_sysstat{stat_id="30000",@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_sysstat{stat_id="30001",@LABELS}[@INTERVAL])) by (@GBLABELS)` | us | | 每秒等待事件次数 | `sum(rate(ob_waitevent_wait_total{@LABELS}[@INTERVAL])) by (@GBLABELS)` | 次/s | | 等待事件平均耗时 | `sum(rate(ob_waitevent_wait_seconds_total{@LABELS}[@INTERVAL])) by (@GBLABELS) / sum(rate(ob_waitevent_wait_total{@LABELS}[@INTERVAL])) by (@GBLABELS)` | s |