获取 Sandbox 指标
调用指标 API 会返回一组带时间戳的指标记录。指标每 5 秒采样一次。使用 SDK 获取 Sandbox 指标
使用 CLI 获取 Sandbox 指标
--follow 可以实时持续输出指标流:
--format json 可以输出机器可读的指标数据:
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
from time import sleep
from ppio_sandbox import PPIO
ppio = PPIO()
sbx = ppio.sandbox.create()
print('Created sandbox:', sbx.sandbox_id)
# 等待指标采集。
sleep(10)
metrics = sbx.get_metrics()
# 也可以通过 ID 获取:
# metrics = ppio.sandbox.get_metrics(sbx.sandbox_id)
print('Metrics:', metrics)
import { PPIO } from 'ppio-sandbox'
const ppio = new PPIO()
const sbx = await ppio.sandbox.create()
console.log('Created sandbox:', sbx.sandboxId)
// 等待指标采集。
await new Promise((resolve) => setTimeout(resolve, 10_000))
const metrics = await sbx.getMetrics()
// 也可以通过 ID 获取:
// const metrics = await ppio.sandbox.getMetrics(sbx.sandboxId)
console.log('Metrics:', metrics)
ppio sandbox metrics <sandboxID>
# 输出示例:
# Sandbox 的指标
#
# [2025-07-25 14:05:55Z] CPU: 8.27% / 2 Cores | Memory: 31 / 484 MiB | Disk: 1445 / 2453 MiB
# [2025-07-25 14:06:00Z] CPU: 0.5% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
# [2025-07-25 14:06:05Z] CPU: 0.1% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
# [2025-07-25 14:06:10Z] CPU: 0.3% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
--follow 可以实时持续输出指标流:
ppio sandbox metrics <sandboxID> --follow
--format json 可以输出机器可读的指标数据:
ppio sandbox metrics <sandboxID> --format json