Get Metric Label Values for Specified Labels

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

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

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
namespaceStringqueryNamespace name 4.10.20
metricNameStringqueryMetric name 4.10.20
startTime (optional)LongqueryStart time 4.10.20
endTime (optional)LongqueryEnd time 4.10.20
labelNames (optional)ListqueryLabel name list for retrieving values 4.10.20
filterLabels (optional)ListqueryLabel filter list. For example, you can specify the label HostUuid=e47f7145f4cd4fca8e2856038ecdf3e1 to select a specific physical host and retrieve the values of labels specified in labelNames. 4.10.20
systemTags (optional)ListquerySystem tags 4.10.20
userTags (optional)ListqueryUser tags 4.10.20

API Response

Response Example

{
  "labelValues": {
    "hostUuid": [
      "host_uuid_1",
      "host_uuid_2"
    ],
    "cpuNum": [
      "0",
      "1",
      "2",
      "4"
    ]
  }
}
NameTypeDescriptionStarting Version
labelValuesMapLabel values4.10.20
successbooleanWhether the get operation succeeded4.10.20
errorErrorCodeFor details, see error4.10.20

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

SDK Examples

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