监控指标查询
v3.5.8+
tcb monitor 命令自 v3.5.8 起提供。
CloudBase CLI 提供统一的监控指标查询入口,支持云函数、文档型数据库、MySQL、云托管、静态网站托管、身份认证、大模型、知识库、网关、用户登录、DB Connector、环境 QPS 等全类型资源的监控数据查询。
查看可用指标 Schema
查看各资源类型支持的监控指标列表。
tcb monitor schema [resource]
- 不传
resource则展示所有资源类型的可用指标 - 传
resource则只展示该类型的指标
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
resource | 资源类型(可选),见下表 | — |
支持的资源类型
| 资源类型 | 说明 |
|---|---|
function | 云函数 |
database | 文档型数据库 |
mysql | MySQL 数据库 |
cloudrun | 云托管 |
hosting | 静态网站托管 |
auth | 身份认证 |
ai | 大模型 |
knowledgebase | 知识库 |
gateway | 网关 |
userlogin | 用户登录 |
dbconnector | DB Connector |
env | 环境 QPS |
示例
# 查看所有可用指标
tcb monitor schema
# 查看云函数可用指标
tcb monitor schema function
# 查看网关可用指标
tcb monitor schema gateway
# 查看环境 QPS 可用指标
tcb monitor schema env
云函数监控
查询云函数的监控指标。
tcb monitor function [function-name] [options]
- 不传
function-name则查询所有函数的概览指标
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
function-name | 云函数名称(可选) | — |
-e, --env-id <envId> | 环境 ID(不传则交互式选择) | — |
--since <since> | 起始时间,支持相对时间格式(如 30s、30m、1h、2d) | 1h |
--until <until> | 结束时间,支持相对时间格式(如 now、5m) | now |
--metric-name <metricName...> | 指定查询的指标名称,不传则查询所有指标。多个指标可用逗号分隔或重复指定 | 全部指标 |
--period <period> | 统计周期(秒):300(5分钟)、3600(1小时)、86400(1天),不传则自动选择 | 自动 |
--json | 输出 JSON,适合脚本消费 | — |
示例
# 查询所有函数的概览指标
tcb monitor function
# 查询 helloWorld 函数的调用次数
tcb monitor function helloWorld --metric-name FunctionInvocation
# 查询最近 1 小时内 helloWorld 的多个指标
tcb monitor function helloWorld --since 1h --metric-name FunctionInvocation --metric-name FunctionFlux
# 指定 1 小时统计周期,查询最近 7 天
tcb monitor function --since 7d --period 3600
# JSON 格式输出
tcb monitor function helloWorld --metric-name FunctionInvocation --json
可用指标
| 指标名 | 说明 |
|---|---|
FunctionCU | 资源用量 |
FunctionInvocation | 调用次数 |
FunctionFlux | 外网出流量(KB) |
FunctionThrottle | 受限次数 |
FunctionConcurrentExecutions | 并发执行个数 |
FunctionTimeout | 函数执行超时次数 |
FunctionGBs | 资源用量(Mb*Ms) |
FunctionError | 错误次数 |
FunctionDuration | 运行时间(ms) |
FunctionConcurrencyMemoryMB | 并发执行内存量 |
FunctionMemOverFlow | 内存超限次数 |
FunctionIdleProvisioned | 预置并发闲置量 |
FunctionProvisionedConcurrency | 预置并发个数 |
文档型数据库监控
查询文档型数据库(NoSQL)的监控指标。
tcb monitor database [collection-name] [options]
- 不传
collection-name则查询所有集合的概览指标
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
collection-name | 集合名称(可选) | — |
-e, --env-id <envId> | 环境 ID(不传则交互式选择) | — |
--since <since> | 起始时间,支持相对时间格式(如 30s、30m、1h、2d) | 1h |
--until <until> | 结束时间,支持相对时间格式(如 now、5m) | now |
--metric-name <metricName...> | 指定查询的指标名称,不传则查询所有指标。多个指标可用逗号分隔或重复指定 | 全部指标 |
--period <period> | 统计周期(秒):300(5分钟)、3600(1小时)、86400(1天),不传则自动选择 | 自动 |
--json | 输出 JSON,适合脚本消费 | — |
示例
# 查询所有集合的监控概览
tcb monitor database
# 查询 users 集合的读请求数
tcb monitor database users --metric-name DbRead
# 查询最近 1 小时内 users 集合的多个指标
tcb monitor database users --since 1h --metric-name DbRead --metric-name DbWrite
# 指定 1 小时统计周期
tcb monitor database --since 7d --period 3600
可用指标
| 指标名 | 说明 |
|---|---|
DbRead | 读请求数 |
DbWrite | 写请求数 |
DbCostTime10ms | 耗时 10ms-50ms 请求数 |
DbCostTime50ms | 耗时 50ms-100ms 请求数 |
DbCostTime100ms | 耗时 100ms 以上请求数 |
DbSizepkg | 容量(MB) |