获取指定标签的监控项数据

GET/zstack/v1/zwatch/metrics/prometheus/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/prometheus/label-values?namespace=ZStack/VM&metricName=CPUIdleUtilization&startTime=1510669197141&endTime=1510669257141&labelNames=CPUNum&filterLabels=VMUuid=ff01ec80fd11327cba7519b66119d900

参数列表

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

API返回

返回示例

{
  "labelValues": {
    "hostUuid": [
      "host_uuid_1",
      "host_uuid_2"
    ],
    "cpuNum": [
      "0",
      "1",
      "2",
      "4"
    ]
  }
}
名字类型描述起始版本
labelValuesMap标签值4.10.20
successboolean获取操作是否成功4.10.20
errorErrorCode详情参考error4.10.20

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

GetPrometheusMetricLabelValueAction action = new GetPrometheusMetricLabelValueAction();
action.namespace = "ZStack/VM";
action.metricName = "CPUIdleUtilization";
action.startTime = 1510669197141;
action.endTime = 1510669257141;
action.labelNames = asList("CPUNum");
action.filterLabels = asList("VMUuid=ff01ec80fd11327cba7519b66119d900");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetPrometheusMetricLabelValueAction.Result res = action.call();

Python SDK

action = GetPrometheusMetricLabelValueAction()
action.namespace = "ZStack/VM"
action.metricName = "CPUIdleUtilization"
action.startTime = 1510669197141
action.endTime = 1510669257141
action.labelNames = [CPUNum]
action.filterLabels = [VMUuid=ff01ec80fd11327cba7519b66119d900]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()