监控指标查询
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) |
MySQL 数据库监控
查询 MySQL 数据库的监控指标。
tcb monitor mysql [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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,适合脚本消费 | — |
示例
# 查询 MySQL 所有监控指标
tcb monitor mysql
# 查询 MySQL 存储容量
tcb monitor mysql --metric-name MysqlStorageUsage
# 查询最近 1 天的 CCU
tcb monitor mysql --metric-name MysqlCCU --since 1d
# 查询多个指标
tcb monitor mysql --metric-name MysqlQps --metric-name MysqlSlowQueries
# 指定 1 小时统计周期
tcb monitor mysql --since 7d --period 3600
可用指标
| 指标名 | 说明 |
|---|---|
MysqlStorageUsage | 容量(MB) |
MysqlCCU | CCU |
MysqlCpuUsageRate | CPU 利用率 |
MysqlDbConnections | 连接数 |
MysqlMemoryUse | 内存使用量(MB) |
MysqlSlowQueries | 慢查询数 |
MysqlTps | 提交数 |
MysqlQps | QPS |
云托管监控
查询云托管服务的监控指标。
tcb monitor cloudrun <service-name> [options]
service-name为必填参数,指定云托管服务名称
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
service-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天),不传则自动选择 | 自动 |
--service-version <serviceVersion> | 指定服务版本,查询该版本的监控数据 | — |
--json | 输出 JSON,适合脚本消费 | — |
示例
# 查询 my-service 服务的所有监控指标
tcb monitor cloudrun my-service
# 查询服务的 QPS
tcb monitor cloudrun my-service --metric-name TkeQPSService
# 查询最近 1 天的 CPU 使用量
tcb monitor cloudrun my-service --metric-name TkeCpuUsedService --since 1d
# 查询多个指标
tcb monitor cloudrun my-service --metric-name TkeQPSService --metric-name TkeRspTimeService
# 指定版本查询
tcb monitor cloudrun my-service --service-version my-service-001
# 指定 1 小时统计周期
tcb monitor cloudrun my-service --since 7d --period 3600
可用指标
| 指标名 | 说明 |
|---|---|
TkeRspTimeService | 响应时间(ms) |
TkeCpuUsedService | CPU 使用量 |
TkeMemUsedService | 内存使用量 |
TkeQPSService | QPS |
TkePodNumService | 实例个数 |
TkeHttpServiceNatPkg | 外网出流量(byte) |
TkeCUUsedService | 内存使用量(CU) |
TkeInvokeNumService | 调用量 |
TkeHttpErrorService | 错误响应(404、500 等) |
静态网站托管监控
查询静态网站托管的监控指标。
tcb monitor hosting [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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 hosting
# 查询流量指标
tcb monitor hosting --metric-name StaticFsFluxPkg
# 查询存储容量
tcb monitor hosting --metric-name StaticFsSizePkg
# 查询最近 7 天的数据
tcb monitor hosting --since 7d --period 86400
可用指标
| 指标名 | 说明 |
|---|---|
StaticFsFluxPkg | 流量(byte) |
StaticFsSizePkg | 存储容量(MB) |
身份认证监控
查询身份认证的监控指标。
tcb monitor auth [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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 auth
# 查询最近 7 天的调用次数
tcb monitor auth --since 7d --period 86400
# JSON 格式输出
tcb monitor auth --json
可用指标
| 指标名 | 说明 |
|---|---|
AuthInvocationNumPkg | 调用次数 |
大模型监控
查询大模型(AI)的监控指标。
tcb monitor ai [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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 ai
# 查询输入 Token 用量
tcb monitor ai --metric-name AIPromptTokenNumPkg
# 查询输出 Token 用量
tcb monitor ai --metric-name AICompletionTokenNumPkg
# 查询最近 7 天的 Token 用量
tcb monitor ai --since 7d --period 86400
可用指标
| 指标名 | 说明 |
|---|---|
AIPromptTokenNumPkg | 输入 Token |
AICompletionTokenNumPkg | 输出 Token |
AITotalTokenNumPkg | 总 Token |
知识库监控
查询知识库的监控指标。
tcb monitor knowledgebase [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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 knowledgebase
# 查询最近 7 天的容量变化
tcb monitor knowledgebase --since 7d --period 86400
# JSON 格式输出
tcb monitor knowledgebase --json
可用指标
| 指标名 | 说明 |
|---|---|
KnowledgeBaseCapacity | 容量(bytes) |
网关监控
查询 HTTP 网关层的服务调用监控指标。通过位置参数 dimension 区分查询维度:api(API 调用链路)和 resource(HTTP 请求资源链路)。
tcb monitor gateway <dimension> [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
dimension | 查询维度(必填),可选值:api / resource | — |
-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天),不传则自动选择 | 自动 |
--api-type <apiType> | 当 dimension=api 时必填,API 类型:wx(小程序 API)或 http_openapi(云开发 API)。不支持与 --resource-id 同时使用 | — |
--resource-id <resourceId> | 当 dimension=resource 时必填,资源标识符,格式为 域名|:|路由|:|资源对象。不支持与 --api-type 同时使用 | — |
--json | 输出 JSON,适合脚本消费 | — |
维度参数约束
- 当
dimension=api时,--api-type必填,不支持--resource-id - 当
dimension=resource时,--resource-id必填,不支持--api-type
示例
# 查询 API 调用链路(api 维度)— 小程序 API
tcb monitor gateway api --api-type wx
# 查询 API 调用链路 — 云开发 API
tcb monitor gateway api --api-type http_openapi
# 查询最近 6 小时的 API 调用链路
tcb monitor gateway api --api-type http_openapi --since 6h
# 查询资源链路(resource 维度)
tcb monitor gateway resource --resource-id "example.com|:|/api/users|:|cloudfunction"
# JSON 格式输出
tcb monitor gateway api --api-type wx --json
可用指标(api 维度)
| 指标名 | 说明 |
|---|---|
GatewayShowAPIInvokeNum | 调用次数 |
GatewayShowAPICostTotal | 请求平均耗时 |
GatewayShowAPIHTTP2XX | HTTP 2xx 请求数 |
GatewayShowAPIHTTPError | HTTP ≥400 请求数 |
可用指标(resource 维度)
| 指标名 | 说明 |
|---|---|
GatewayShowHttpInvokeNum | 调用次数 |
GatewayShowHttpCostTotal | 请求平均耗时 |
GatewayShowHttpHTTP2XX | HTTP 2xx 请求数 |
GatewayShowHttpHTTPError | HTTP ≥400 请求数 |
用户登录监控
查询用户登录的监控指标。
tcb monitor userlogin [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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 userlogin
# 查询全部用户登录日活
tcb monitor userlogin --metric-name DayActiveLoginAllUser
# 查询最近 1 天的匿名用户登录日活
tcb monitor userlogin --metric-name DayActiveLoginAnonymousUser --since 1d
# JSON 格式输出
tcb monitor userlogin --json
可用指标
| 指标名 | 说明 |
|---|---|
DayActiveLoginAnonymousUser | 匿名用户登录日活 |
DayActiveLoginAllUser | 全部用户登录日活 |
DayActiveLoginExternalUser | 外部用户登录日活 |
DayActiveLoginInternalUser | 内部用户登录日活 |
DB Connector 监控
查询 DB Connector(数据库连接器)的监控指标。
tcb monitor dbconnector <connector-id> [options]
connector-id为必填参数,指定连接器 ID
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
connector-id | 连接器 ID(必填) | — |
-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,适合脚本消费 | — |
示例
# 查询 my-connector 的所有监控指标
tcb monitor dbconnector my-connector-id
# 查询 my-connector 的读请求数
tcb monitor dbconnector my-connector-id --metric-name MongoConnectorRead
# 查询最近 30 分钟的调用次数
tcb monitor dbconnector my-connector-id --metric-name MongoConnectorInvokeNum --since 30m
# JSON 格式输出
tcb monitor dbconnector my-connector-id --json
可用指标
| 指标名 | 说明 |
|---|---|
MongoConnectorRead | 读请求数 |
MongoConnectorWrite | 写请求数 |
MongoConnectorCostTime10ms | 耗时 10ms-50ms 请求数 |
MongoConnectorCostTime50ms | 耗时 50ms-100ms 请求数 |
MongoConnectorCostTime100ms | 耗时 100ms 以上请求数 |
MongoConnectorInvokeNum | 调用次数 |
环境 QPS 监控
查询环境 QPS 的监控指标。
tcb monitor env [options]
参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-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,适合脚本消费 | — |
示例
# 查询环境 QPS
tcb monitor env
# 查询环境总 QPS
tcb monitor env --metric-name EnvQPSAll
# 查询最近 1 小时的环境 QPS
tcb monitor env --since 1h
# 指定 1 小时统计周期
tcb monitor env --since 7d --period 3600
# JSON 格式输出
tcb monitor env --json
可用指标
| 指标名 | 说明 |
|---|---|
EnvQPSAll | 环境总 QPS |
相关命令
tcb logs search— 日志检索tcb env list— 查看可用环境