获取metric的标签值

GET/zstack/v1/zwatch/metrics/label-values

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics/label-values?namespace=ZStack/VM&metricName=CPUIdleUtilization&startTime=1.58806818E9&endTime=1.58806824E9&labelNames=CPUNum&filterLabels=VMUuid=e47f7145f4cd4fca8e2856038ecdf3e1

参数列表

名字类型位置描述可选值起始版本
namespaceStringquery名字空间名称 2.3
metricNameStringquery监控指标名称 2.3
labelNamesListquery要获取值得标签名列表 2.3
filterLabels (可选)Listquery标签过滤器列表,例如可以指定标签HostUuid=e47f7145f4cd4fca8e2856038ecdf3e1来选择特定主机的,labelNames中指定标签的值 2.3
startTime (可选)Longquery起始时间 3.9.0
endTime (可选)Longquery结束时间 3.9.0
systemTags (可选)Listquery系统标签 2.3
userTags (可选)Listquery用户标签 2.3

API返回

返回示例

{
  "labels": [
    {
      "VMUuid": "e47f7145f4cd4fca8e2856038ecdf3e1",
      "CPUNum": "1"
    }
  ]
}
名字类型描述起始版本
labelsList标签值0.6
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error0.6

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10010.6
descriptionString错误的概要描述0.6
detailsString错误的详细信息0.6
elaborationString保留字段,默认为null0.6
opaqueLinkedHashMap保留字段,默认为null0.6
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null0.6

SDK示例

Java SDK

GetMetricLabelValueAction action = new GetMetricLabelValueAction();
action.namespace = "ZStack/VM";
action.metricName = "CPUIdleUtilization";
action.startTime = 1.58806818E9;
action.endTime = 1.58806824E9;
action.labelNames = asList("CPUNum");
action.filterLabels = asList("VMUuid=e47f7145f4cd4fca8e2856038ecdf3e1");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetMetricLabelValueAction.Result res = action.call();

Python SDK

GetMetricLabelValueAction action = GetMetricLabelValueAction()
action.namespace = "ZStack/VM"
action.metricName = "CPUIdleUtilization"
action.startTime = 1.58806818E9
action.endTime = 1.58806824E9
action.labelNames = [CPUNum]
action.filterLabels = [VMUuid=e47f7145f4cd4fca8e2856038ecdf3e1]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetMetricLabelValueAction.Result res = action.call()