接口参考实例与控制台
获取实例历史监控
GET /api/v1/instances/{instance_id}/metrics,getInstanceMetricsHistory 的请求参数和响应结构。
GET /api/v1/instances/{instance_id}/metrics
| 项目 | 内容 |
|---|---|
| 操作标识 | getInstanceMetricsHistory |
| 认证 | 登录会话 Cookie |
按实例授权查询 CPU、客户机内存、虚拟磁盘 I/O 和网卡历史数据。60 秒采样、保留 365 天。缺失值保留为空。
请求参数
| 名称 | 位置 | 必填 | 类型 | 说明与约束 |
|---|---|---|---|---|
| instance_id | path | 是 | string | 格式:uuid |
| range | query | 否 | string | 可选值:"hour"、"day"、"week"、"month"、"year";默认 "hour" |
响应
| HTTP 状态 | 含义 |
|---|---|
| 200 | OK |
| 400 | 请求无法完成 |
| 401 | 请求无法完成 |
| 403 | 请求无法完成 |
| 404 | 请求无法完成 |
| 409 | 请求无法完成 |
| 503 | 请求无法完成 |
200 · application/json 响应结构
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
| data | InstanceMetricsHistory | 是 | — |
{
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"$ref": "#/$defs/InstanceMetricsHistory"
}
},
"$defs": {
"InstanceMetricsHistory": {
"type": "object",
"additionalProperties": false,
"properties": {
"start": {
"type": "integer",
"format": "int64"
},
"end": {
"type": "integer",
"format": "int64"
},
"step_seconds": {
"type": "integer",
"minimum": 60
},
"sample_interval_seconds": {
"type": "integer",
"enum": [
60
]
},
"retention_days": {
"type": "integer",
"enum": [
365
]
},
"pending_samples": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"series": {
"type": "array",
"items": {
"$ref": "#/$defs/HostMetricSeries"
}
},
"instance_id": {
"type": "string",
"format": "uuid"
}
},
"required": [
"start",
"end",
"step_seconds",
"sample_interval_seconds",
"retention_days",
"pending_samples",
"series",
"instance_id"
]
},
"HostMetricSeries": {
"type": "object",
"additionalProperties": false,
"properties": {
"metric": {
"type": "string"
},
"device": {
"type": "string"
},
"path": {
"type": "string"
},
"points": {
"type": "array",
"items": {
"$ref": "#/$defs/HostMetricPoint"
}
}
},
"required": [
"metric",
"points"
]
},
"HostMetricPoint": {
"type": "object",
"additionalProperties": false,
"properties": {
"timestamp": {
"type": "integer",
"format": "int64",
"description": "Unix 毫秒"
},
"value": {
"type": "number",
"nullable": true,
"description": "缺失数据为 null,不以 0 填充"
}
},
"required": [
"timestamp",
"value"
]
}
}
}400 / 401 / 403 / 404 / 409 / 503 · application/json 响应结构
{
"$ref": "#/$defs/ErrorResponse",
"$defs": {
"ErrorResponse": {
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"$ref": "#/$defs/ErrorDetail"
},
"request_id": {
"type": "string"
}
},
"required": [
"error",
"request_id"
]
},
"ErrorDetail": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string",
"enum": [
"NOT_IMPLEMENTED",
"NOT_FOUND",
"AUTH_REQUIRED",
"FORBIDDEN",
"VALIDATION_FAILED",
"CONFLICT",
"SERVICE_UNAVAILABLE",
"INTERNAL_ERROR",
"RATE_LIMITED"
]
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
},
"fields": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"required": [
"code",
"message",
"retryable"
]
}
}
}响应中的 request_id 用于排查请求;异步操作以任务最终状态为准。参阅调用约定、异步任务和错误处理。
本页由版本化 OpenAPI 契约生成。通用资源响应允许的任意字段以运行服务为准,不据此推断尚未定义的字段。
