Get Metric Data

GET/zstack/v1/zwatch/metrics

Headers

Authorization: OAuth the-session-uuid

Curl Example

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

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
namespaceStringqueryNamespace 2.3
metricNameStringqueryMetric 2.3
startTime (optional)LongqueryStart time 2.3
endTime (optional)LongqueryEnd time 2.3
period (optional)IntegerqueryData granularity 2.3
labels (optional)ListqueryFilter labels 2.3
systemTags (optional)ListquerySystem tags 2.3
userTags (optional)ListqueryUser tags 2.3
functions (optional)ListqueryFunction list 2.3
offsetAheadOfCurrentTime (optional)Longquery  2.3

API Response

Response Example

{
  "data": [
    {
      "value": 101.02,
      "time": 1519829245957.0,
      "labels": {
        "VMUuid": "9304ab73d9b84852ad1d5061fd4760a5"
      }
    }
  ]
}
NameTypeDescriptionStarting Version
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error2.3
dataListFor details, see data2.3

error

NameTypeDescriptionStarting Version
codeStringError code. The globally unique error identifier, for example, SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field. Default is null0.6
opaqueLinkedHashMapReserved field. Default is null0.6
causeErrorCodeRoot error. The source error that caused the current error. This field is null if no root error exists0.6

data

NameTypeDescriptionStarting Version
valuedoubleMetric value0.6
timelongRecord generation time0.6
labelsMapLabels0.6

SDK Examples

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()