沙箱指标
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
GET
/e2b/sandboxes/{sandboxID}/metrics● 支持请求参数
sandboxIDstring必填path:
startinteger可选query: Unix timestamp for the start of the interval, in seconds, for which the metrics
endinteger可选query: Unix timestamp for the end of the interval, in seconds, for which the metrics
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/e2b/sandboxes/sbx_123/metrics \
-H "X-API-Key: $PRAXIS_API_KEY"Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
from e2b import Sandbox
opts = dict(
api_key="$PRAXIS_API_KEY",
api_url="https://api.deepraxis.com/e2b",
domain="sandbox.praxisusercontent.com",
)
metrics = Sandbox.get_metrics("sbx_123", **opts)
print(metrics)TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import { Sandbox } from "e2b";
const opts = {
apiKey: "$PRAXIS_API_KEY",
apiUrl: "https://api.deepraxis.com/e2b",
domain: "sandbox.praxisusercontent.com",
};
const metrics = await Sandbox.getMetrics("sbx_123", opts);
console.log(metrics);响应示例 200
[]响应
HTTP 200
Successfully returned the sandbox metrics
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| [].timestamp | string | Timestamp of the metric entry |
| [].timestampUnix | integer | Timestamp of the metric entry in Unix time (seconds since epoch) |
| [].cpuCount | integer | Number of CPU cores |
| [].cpuUsedPct | number | CPU usage percentage |
| [].memUsed | integer | Memory used in bytes |
| [].memTotal | integer | Total memory in bytes |
| [].memCache | integer | Cached memory (page cache) in bytes |
| [].diskUsed | integer | Disk used in bytes |
| [].diskTotal | integer | Total disk space in bytes |