GPU接口文档
GPU实例
获取实例监控数据

GetCompShareInstanceMonitor — 获取实例监控数据

接口说明

获取优云智算 GPU 实例的监控指标(CPU、内存、GPU、磁盘使用率等)。控制台实例列表与「用量详情」均调用本接口。

调用提示Region 须与实例所在地域一致;UHostIds数组(HTTP 表单编码为 UHostIds.0UHostIds.1 …)。仅查最近快照时,也可使用 DescribeCompShareInstance 返回的 MonitorMessages 字段。

使用限制

  • 支持批量查询多个实例;具体返回指标以接口为准。
  • 并发查询建议不超过 10 个实例 ID。

请求参数

名称类型必填描述示例值
ActionString接口名称GetCompShareInstanceMonitor
RegionString地域,须与实例一致cn-wlcb
ZoneString可用区cn-wlcb-01
UHostIds.NString【数组】实例 ID。UHostIds.0 为第一台,UHostIds.1 为第二台。不传则返回当前 Region 下符合条件的实例uhost-xxxx

响应参数

名称类型描述示例值
ActionString响应名称GetCompShareInstanceMonitorResponse
RetCodeInteger返回码,0 为成功0
DataObject监控数据

Data 结构

名称类型描述
ListArray of Object实例监控数据列表

List 元素结构

名称类型描述
UHostIdString实例 ID
MetricsArray of Object监控指标列表

Metrics 元素结构

名称类型描述
MetricKeyString指标名称
TagsObject标签(如 uuidgpu_bus_id 等)
ResultsArray of Object指标数据

Results / Values

名称类型描述
ValuesArray of Object时间序列数据点
Values[].TimestampIntegerUnix 时间戳
Values[].ValueFloat指标值

常见 MetricKey

MetricKey说明
uhost_cpu_usedCPU 使用率(%)
cloudwatch_memory_usage内存使用率(%)
cloudwatch_sys_disk_used_per系统盘使用率(%)
cloudwatch_data_disk_used_per数据盘使用率(%)
cloudwatch_gpu_utilGPU 使用率(%)
cloudwatch_gpu_memory_usageGPU 显存使用率(%)

请求示例

Python(使用 UCloud SDK)

pip install --upgrade ucloud-sdk-python3
from ucloud.core import exc
from ucloud.client import Client
 
 
def main():
    client = Client({
        "region": "cn-wlcb",
        "public_key": "my_public_key",
        "private_key": "my_private_key",
        "base_url": "https://api.compshare.cn",
    })
 
    try:
        resp = client.ucompshare().get_comp_share_instance_monitor({
            "UHostIds": ["uhost-xxxx"],
        })
        for inst in resp.get("Data", {}).get("List", []):
            print(f"实例 {inst.get('UHostId')}:")
            for metric in inst.get("Metrics", []):
                print(f"  {metric.get('MetricKey')}")
    except exc.UCloudException as e:
        print(e)
 
 
if __name__ == "__main__":
    main()

Go(使用 UCloud SDK)

req := client.NewGetCompShareInstanceMonitorRequest()
req.UHostIds = []string{"uhost-xxxx"}
 
resp, err := client.GetCompShareInstanceMonitor(req)

HTTP(表单数组)

POST https://api.compshare.cn/
Action=GetCompShareInstanceMonitor
&Region=cn-wlcb
&Zone=cn-wlcb-01
&UHostIds.0=uhost-xxxx

故障排查

现象处理建议
调不通 / RetCode 非 0确认 RegionZoneDescribeCompShareInstance 中实例一致
参数错误使用 UHostIds 数组,勿将单个 ID 写成 UHostId(除非网关兼容)
仅需当前使用率调用 DescribeCompShareInstance,读取 MonitorMessages

响应示例

{
  "Action": "GetCompShareInstanceMonitorResponse",
  "RetCode": 0,
  "Data": {
    "List": [
      {
        "UHostId": "uhost-xxxx",
        "Metrics": [
          {
            "MetricKey": "uhost_cpu_used",
            "Results": [
              {
                "Values": [
                  {"Timestamp": 1712563200, "Value": 35.2}
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}
Copyright © 2026 沪ICP备12020087号-61