
# 查询服务监控信息
#### 功能介绍
查询服务监控信息。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/ModelArts/doc?api=ShowServiceMonitorInfo)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-modelarts/modelarts_03_0138.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                          | 访问级别 | 资源类型（\*为必须） | 条件键                       | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | modelarts:service:getMonitor | Read | service \*  | g:ResourceTag/\<tag-key\> | -  | -      |
     
  
 
#### URI
GET /v1/{project_id}/services/{service_id}/monitor
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                               |
|:---|:---|:---|:---|
| project_id | 是    | String | 用户项目ID。获取方法请参见[获取项目ID和名称](https://support.huaweicloud.com/api-modelarts/modelarts_03_0147.html)。 |
| service_id | 是    | String | 服务ID。                                                                                            |
   
表2Query参数 
| 参数      | 是否必选 | 参数类型   | 描述                                         |
|:---|:---|:---|:---|
| node_id | 否    | String | 待查询的边缘节点ID，仅当infer_type为edge时可指定，默认查询所有节点。 |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                       |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。通过调用IAM服务获取用户Token接口获取（响应消息头中X-Subject-Token的值）。 |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数                             | 参数类型                                                                        | 描述                          |
|:---|:---|:---|
| service_name                   | String                                                                      | 服务名称。                       |
| service_id                     | String                                                                      | 服务ID。                       |
| monitors                       | Array of [Monitor] objects | 监控信息详情。                     |
| service_running_instance_count | Integer                                                                     | 服务运行中实例数量。                  |
| service_instance_count         | Integer                                                                     | 服务实例数量。                     |
| req_count_per_min              | Long                                                                        | 服务分钟调用量，这里指当前时间上一分钟的服务调用总量。 |
   
 表5Monitor 
| 参数                           | 参数类型    | 描述                 |
|:---|:---|:---|
| failed_times                 | Integer | 模型实例调用失败次数，在线服务字段。 |
| model_version                | String  | 模型版本，在线服务字段。       |
| cpu_memory_total             | Integer | 总内存，单位MB。          |
| gpu_usage                    | Float   | 已使用GPU个数。          |
| node_name                    | String  | 节点名称，边缘服务字段。       |
| gpu_total                    | Float   | 总GPU个数。            |
| model_id                     | String  | 模型ID，在线服务字段。       |
| invocation_times             | Integer | 模型实例的总调用次数，在线服务字段。 |
| cpu_core_usage               | Float   | 已使用CPU核数。          |
| cpu_core_total               | Float   | 总CPU核数。            |
| model_name                   | String  | 模型名称，在线服务字段。       |
| cpu_memory_usage             | Integer | 已使用内存，单位MB。        |
| node_id                      | String  | 边缘节点ID，边缘服务字段。     |
| model_running_instance_count | Integer | 模型运行中实例数。          |
| model_instance_count         | Integer | 模型实例数。             |
| gpu_memory_total             | Float   | gpu总显存，单位MB。       |
| gpu_memory_usage             | Float   | 已使用gpu显存，单位MB。     |
| npu_total                    | Float   | 总NPU个数。            |
| npu_usage                    | Float   | 已使用NPU个数。          |
| npu_memory_total             | Float   | npu总显存，单位MB。       |
| npu_memory_usage             | Float   | 已使用npu显存，单位MB。     |
   
#### 请求示例
```
GET https://{endpoint}/v1/{project_id}/services/{service_id}/monitor
```
#### 响应示例
**状态码：200**
监控信息
```
{
  "service_name" : "mnist",
  "service_id" : "195c1f2d-136d-40af-a0f3-db5717d2634a",
  "monitors" : [ {
    "failed_times" : 1,
    "model_version" : "1.0.0",
    "cpu_core_total" : 4,
    "cpu_memory_total" : 8192,
    "model_name" : "mnist",
    "gpu_usage" : 0.6,
    "cpu_memory_usage" : 2011,
    "gpu_total" : 1,
    "model_id" : "0e07b41b-173e-42db-8c16-8e1b44cc0d44",
    "invocation_times" : 50,
    "cpu_core_usage" : 2.4
  } ]
}
```
#### 状态码
| 状态码 | 描述   |
|:---|:---|
| 200 | 监控信息 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-modelarts/modelarts_03_0095.html)。
