GetMetricData

API Request

URLs
GET zstack/v1/zwatch/metrics
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics?namespace=ZStack/VM&metricName=CPUIdleUtilization&startTime=1.588831825415E12&period=30.0&labels=VMUuid=b89391d8b93b470a99055001a4383cc7&labels=CPUNum=4
Request Parameters
Name Type Location Description Optional Value Starting Version
namespace String query The namespace. 2.3
metricName String query The metric name. 2.3
startTime Long query Optional. The start time. 2.3
endTime Long query Optional. The end time. 2.3
period Integer query Optional. The interval for returning data. 2.3
labels List query Optional. The filter labels. 2.3
systemTags List query Optional. The system tags. 2.3
userTags List query Optional. The user tags. 2.3
functions List query Optional. The function list. 2.3
offsetAheadOfCurrentTime Long query Optional. 2.3

API Response

Sample Response
{
  "data": [
    {
      "value": 101.02,
      "time": 1.519829245957E12,
      "labels": {
        "VMUuid": "9304ab73d9b84852ad1d5061fd4760a5"
      }
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
data List See data. 2.3
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 0.6
description String The brief description of the error. 0.6
details String The details about the error. 0.6
elaboration String The reserved field. Default value: null. 0.6
opaque LinkedHashMap The reserved field. Default value: null. 0.6
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 0.6
#data
Name Type Description Starting Version
value double The metric value. 0.6
time long The time when the record was generated. 0.6
labels Map The label values. 0.6

SDK Sample

Java SDK
GetMetricDataAction action = new GetMetricDataAction();
action.namespace = "ZStack/VM";
action.metricName = "CPUIdleUtilization";
action.startTime = 1.519829246005E12;
action.period = 30.0;
action.labels = asList("VMUuid=3bb5b754320a4331bd907f10d8683568","CPUNum=4");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetMetricDataAction.Result res = action.call();
Python SDK
GetMetricDataAction action = GetMetricDataAction()
action.namespace = "ZStack/VM"
action.metricName = "CPUIdleUtilization"
action.startTime = 1.519829246005E12
action.period = 30.0
action.labels = [VMUuid=b577cfe6aad447c1b2e793fdc6d7975b, CPUNum=4]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetMetricDataAction.Result res = action.call()