Time Series Data (Metric)
GetAllMetricMetadata
API Request
URLs
GET zstack/v1/zwatch/metrics/meta-dataHeaders
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics/meta-data?name=VMHAProcessParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| name (optional) | String | query | Metric name | 3.9.0 | |
| namespace (optional) | String | query | Metric namespace | 3.9.0 | |
| systemTags (optional) | List | query | System tags | 2.3 | |
| userTags (optional) | List | query | User tags | 2.3 |
API Response
Response Example
{
"metrics": [
{
"namespace": "ZStack/VM",
"name": "org.zstack.zwatch.datatype.Metric@4efa6b58",
"description": "CPUIdleUtilization",
"labelNames": [
"VMUuid",
"CPUNum"
],
"driver": "PrometheusDatabaseDriver"
}
]
}#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. The globally unique error identifier, for example, SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if no root error exists | 0.6 |
#metrics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| namespace | String | Namespace | 2.3 |
| name | String | Resource name | 2.3 |
| description | String | Description | 3.9.0 |
| labelNames | List | Label names | 2.3 |
SDK Examples
Java
SDK
GetAllMetricMetadataAction action = new GetAllMetricMetadataAction();
action.name = "VMHAProcess";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAllMetricMetadataAction.Result res = action.call();Python
SDK
GetAllMetricMetadataAction action = GetAllMetricMetadataAction()
action.name = "VMHAProcess"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetAllMetricMetadataAction.Result res = action.call()GetMetricData
API Request
URLs
GET zstack/v1/zwatch/metricsHeaders
Authorization: OAuth the-session-uuidCurl 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=4Parameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| namespace | String | query | Namespace | 2.3 | |
| metricName | String | query | Metric | 2.3 | |
| startTime (optional) | Long | query | Start time | 2.3 | |
| endTime (optional) | Long | query | End time | 2.3 | |
| period (optional) | Integer | query | Data granularity | 2.3 | |
| labels (optional) | List | query | Filter labels | 2.3 | |
| systemTags (optional) | List | query | System tags | 2.3 | |
| userTags (optional) | List | query | User tags | 2.3 | |
| functions (optional) | List | query | Function list | 2.3 | |
| offsetAheadOfCurrentTime (optional) | Long | query | Optional. The offset ahead of current time. | 2.3 |
API Response
Response Example
{
"data": [
{
"value": 101.02,
"time": 1.519829245957E12,
"labels": {
"VMUuid": "9304ab73d9b84852ad1d5061fd4760a5"
}
}
]
}#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. The globally unique error identifier, for example, SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if no root error exists | 0.6 |
#data
| Name | Type | Description | Starting Version |
|---|---|---|---|
| value | double | Metric value | 0.6 |
| time | long | Record generation time | 0.6 |
| labels | Map | Labels | 0.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()GetMetricLabelValue
API Request
URLs
GET zstack/v1/zwatch/metrics/label-valuesHeaders
Authorization: OAuth the-session-uuidCurl Example
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=e47f7145f4cd4fca8e2856038ecdf3e1Parameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| namespace | String | query | Namespace name | 2.3 | |
| metricName | String | query | Metric name | 2.3 | |
| labelNames | List | query | Label name list for retrieving values | 2.3 | |
| filterLabels (optional) | List | query | Label filter list. For example, you can specify the label HostUuid=e47f7145f4cd4fca8e2856038ecdf3e1 to select a specific host and retrieve the values of labels specified in labelNames. | 2.3 | |
| startTime (optional) | Long | query | Start time | 3.9.0 | |
| endTime (optional) | Long | query | End time | 3.9.0 | |
| systemTags (optional) | List | query | System tags | 2.3 | |
| userTags (optional) | List | query | User tags | 2.3 |
API Response
Response Example
{
"labels": [
{
"VMUuid": "e47f7145f4cd4fca8e2856038ecdf3e1",
"CPUNum": "1"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| labels | List | Label values | 0.6 |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. The globally unique error identifier, for example, SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if no root error exists | 0.6 |
SDK Examples
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()PutMetricData
API Request
URLs
POST zstack/v1/zwatch/metricsHeaders
Authorization: OAuth the-session-uuidBody
Note: The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.
{
"params": {
"namespace": "MyNameSpace",
"data": [
{
"metricName": "UserDefinedName",
"value": 100.01,
"labels": {
"label1": "value1"
}
}
]
},
"systemTags": [],
"userTags": []
}
Note: The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"namespace":"MyNameSpace","data":[{"metricName":"UserDefinedName","value":100.01,"labels":{"label1":"value1"}}]}}' \
http://localhost:8080/zstack/v1/zwatch/metricsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| namespace | String | body (included in the params structure) | Custom namespace name | 2.3 | |
| data | List | body (included in the params structure) | Data | 2.3 | |
| systemTags (optional) | List | body | System tags | 2.3 | |
| userTags (optional) | List | body | User tags | 2.3 |
API Response
On success, this API returns an empty JSON structure {}. On failure, the returned JSON structure contains an error field, for example:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
Java
SDK
PutMetricDataAction action = new PutMetricDataAction();
action.namespace = "MyNameSpace";
action.data = asList([metricName:UserDefinedName, value:100.01, labels:[label1:value1]]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
PutMetricDataAction.Result res = action.call();Python
SDK
PutMetricDataAction action = PutMetricDataAction()
action.namespace = "MyNameSpace"
action.data = [[metricName:UserDefinedName, value:100.01, labels:[label1:value1]]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
PutMetricDataAction.Result res = action.call()CreateMetricDataHttpReceiver
API Request
URLs
POST zstack/v1/zwatch/metrics/httpreceiversHeaders
Authorization: OAuth the-session-uuidBody
Note: The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.
{
"params": {
"name": "CloudMonitor",
"url": "http://127.0.0.1/xxx",
"defaultEnable": true
},
"systemTags": [],
"userTags": []
}
Note: The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"CloudMonitor","url":"http://127.0.0.1/xxx","defaultEnable":true}}' \
http://localhost:8080/zstack/v1/zwatch/metrics/httpreceiversParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body (included in the params structure) |
Resource name | 0.6 | |
| url | String | body (included in the params structure) |
The URL. | 0.6 | |
| description (optional) | String | body (included in the params structure) |
Detailed description of the resource | 0.6 | |
| defaultEnable (optional) | boolean | body (included in the params structure) |
Optional. Whether default is enabled. | 0.6 | |
| resourceUuid (optional) | String | body (included in the params structure) |
Resource UUID | 0.6 | |
| tagUuids (optional) | List | body (included in the params structure) |
Tag UUID list | 3.4.0 | |
| systemTags (optional) | List | body | System tags | 0.6 | |
| userTags (optional) | List | body | User tags | 0.6 |
API Response
Response Example
{
"inventory": {
"uuid": "3c4b2b282e4134579df0b8f74fb9a2b7",
"name": "CloudMonitor",
"url": "http://127.0.0.1/xxx",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"state": "Enabled"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | Whether the operation succeeded. | 0.6 |
| inventory | MetricDataHttpReceiverInventory | For details, see inventory | 0.6 |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 0.6 |
| name | String | Resource name | 0.6 |
| url | String | The URL. | 0.6 |
| description | String | Detailed description of the resource | 0.6 |
| createDate | Timestamp | Creation time | 0.6 |
| lastOpDate | Timestamp | Last modification time | 0.6 |
| state | ReceiverState | For details, see state | 0.6 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Enabled | ReceiverState | Whether the resource is enabled. | 0.6 |
| Disabled | ReceiverState | The Disabled value. | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. The globally unique error identifier, for example, SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if no root error exists | 0.6 |
SDK Examples
Java
SDK
CreateMetricDataHttpReceiverAction action = new CreateMetricDataHttpReceiverAction();
action.name = "CloudMonitor";
action.url = "http://127.0.0.1/xxx";
action.defaultEnable = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateMetricDataHttpReceiverAction.Result res = action.call();Python
SDK
CreateMetricDataHttpReceiverAction action = CreateMetricDataHttpReceiverAction()
action.name = "CloudMonitor"
action.url = "http://127.0.0.1/xxx"
action.defaultEnable = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateMetricDataHttpReceiverAction.Result res = action.call()DeleteMetricDataHttpReceiver
API Request
URLs
DELETE zstack/v1/zwatch/metrics/httpreceivers/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers/8a02129f4a5b3a2dad0d9136f90d5b08Parameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | Resource UUID. Uniquely identifies the resource | 0.6 | |
| deleteMode (optional) | String | body | Deletion mode (Permissive / Enforcing, Permissive) | 0.6 | |
| systemTags (optional) | List | body | System tags | 0.6 | |
| userTags (optional) | List | body | User tags | 0.6 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains an error field, for example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
Java
SDK
DeleteMetricDataHttpReceiverAction action = new DeleteMetricDataHttpReceiverAction();
action.uuid = "8a02129f4a5b3a2dad0d9136f90d5b08";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteMetricDataHttpReceiverAction.Result res = action.call();Python
SDK
DeleteMetricDataHttpReceiverAction action = DeleteMetricDataHttpReceiverAction()
action.uuid = "8a02129f4a5b3a2dad0d9136f90d5b08"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteMetricDataHttpReceiverAction.Result res = action.call()QueryMetricDataHttpReceiver
API Request
URLs
GET zstack/v1/zwatch/metrics/httpreceivers
GET zstack/v1/zwatch/metrics/httpreceivers/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers?q=name=CloudMonitorcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers/6e17a72176453e9e9a4b2783d1219fe4Queryable Fields
Run the CLI command line tool, enter QueryMetricDataHttpReceiver, and press Tab to view all queryable fields and cross-table queryable resource names.
API Response
Response Example
{
"inventories": [
{
"uuid": "77fa620b8d36311ca413c1bfc661c207",
"name": "CloudMonitor",
"url": "http://127.0.0.1/xxx",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"state": "Enabled"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | Whether the operation succeeded. | 0.6 |
| inventories | List | For details, see inventories | 0.6 |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error | 0.6 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 0.6 |
| name | String | Resource name | 0.6 |
| url | String | The URL. | 0.6 |
| description | String | Detailed description of the resource | 0.6 |
| createDate | Timestamp | Creation time | 0.6 |
| lastOpDate | Timestamp | Last modification time | 0.6 |
| state | ReceiverState | For details, see state | 0.6 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Enabled | ReceiverState | Whether the resource is enabled. | 0.6 |
| Disabled | ReceiverState | The Disabled value. | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. The globally unique error identifier, for example, SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if no root error exists | 0.6 |
SDK Examples
Java
SDK
QueryMetricDataHttpReceiverAction action = new QueryMetricDataHttpReceiverAction();
action.conditions = asList("name=CloudMonitor");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryMetricDataHttpReceiverAction.Result res = action.call();Python
SDK
QueryMetricDataHttpReceiverAction action = QueryMetricDataHttpReceiverAction()
action.conditions = ["name=CloudMonitor"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryMetricDataHttpReceiverAction.Result res = action.call()CreateMetricTemplate
API Request
URLs
POST zstack/v1/zwatch/metrics/httpreceivers/templatesHeaders
Authorization: OAuth the-session-uuidBody
Note: The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.
{
"params": {
"receiverUuid": "7c10e325f9e232e489062a190cc1dc2a",
"template": "{ \"metricName\":\"${METRIC_NAME}\",\n \"regionId\":\"cn-shanghai\",\n \"instanceId\":\"${RESOURCE_UUID}\",\n \"resource\":\"vm/${RESOURCE_NAME}\",\n \"dimensions\":{\n \"instanceId\":\"${METRIC_LABLES.get(\u0027VMUuid\u0027)}\",\n \"device\":\"${METRIC_LABLES.get(\u0027DiskDeviceLetter\u0027)}\"\n },\n \"value\":${METRIC_VALUE},\n \"ts\":${METRIC_TIME}\n}",
"namespace": "ZStack/VM",
"metricName": "DiskReadOps",
"labelsJsonStr": "[\u0027VMUuid\u003d95e5885772de4f2bb3e05eba98a43cd0\u0027]"
},
"systemTags": [],
"userTags": []
}
Note: The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"receiverUuid":"7c10e325f9e232e489062a190cc1dc2a","template":"{ \"metricName\":\"${METRIC_NAME}\",\n \"regionId\":\"cn-shanghai\",\n \"instanceId\":\"${RESOURCE_UUID}\",\n \"resource\":\"vm/${RESOURCE_NAME}\",\n \"dimensions\":{\n \"instanceId\":\"${METRIC_LABLES.get('VMUuid')}\",\n \"device\":\"${METRIC_LABLES.get('DiskDeviceLetter')}\"\n },\n \"value\":${METRIC_VALUE},\n \"ts\":${METRIC_TIME}\n}","namespace":"ZStack/VM","metricName":"DiskReadOps","labelsJsonStr":"['VMUuid=95e5885772de4f2bb3e05eba98a43cd0']"}}' \
http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers/templatesParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| receiverUuid | String | body (included in the params structure) |
The receiver UUID. | 0.6 | |
| template | String | body (included in the params structure) |
The template. | 0.6 | |
| namespace | String | body (included in the params structure) |
The namespace. | 0.6 | |
| metricName | String | body (included in the params structure) |
The metric name. | 0.6 | |
| labelsJsonStr (optional) | String | body (included in the params structure) |
Optional. The labels json str. | 0.6 | |
| description (optional) | String | body (included in the params structure) |
Detailed description of the resource | 0.6 | |
| resourceUuid (optional) | String | body (included in the params structure) |
Resource UUID | 0.6 | |
| tagUuids (optional) | List | body (included in the params structure) |
Tag UUID list | 3.4.0 | |
| systemTags (optional) | List | body | System tags | 0.6 | |
| userTags (optional) | List | body | User tags | 0.6 |
API Response
Response Example
{
"inventory": {
"uuid": "b143e113525d3fbaa56bf9be7fa15ccf",
"receiverUuid": "95d0c874bdec350cbb963f97ae9f3a13",
"template": "{ \"metricName\":\"${METRIC_NAME}\",\n \"regionId\":\"cn-shanghai\",\n \"instanceId\":\"${RESOURCE_UUID}\",\n \"resource\":\"vm/${RESOURCE_NAME}\",\n \"dimensions\":{\n \"instanceId\":\"${METRIC_LABLES.get(\u0027VMUuid\u0027)}\",\n \"device\":\"${METRIC_LABLES.get(\u0027DiskDeviceLetter\u0027)}\"\n },\n \"value\":${METRIC_VALUE},\n \"ts\":${METRIC_TIME}\n}",
"namespace": "ZStack/VM",
"metricName": "DiskReadOps",
"labelsJsonStr": "[\u0027VMUuid\u003d95e5885772de4f2bb3e05eba98a43cd0\u0027]",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 0.6 |
| receiverUuid | String | The receiver UUID. | 0.6 |
| template | String | The template. | 0.6 |
| namespace | String | The namespace. | 0.6 |
| metricName | String | The metric name. | 0.6 |
| labelsJsonStr | String | The labels json str. | 0.6 |
| description | String | Detailed description of the resource | 0.6 |
| createDate | Timestamp | Creation time | 0.6 |
| lastOpDate | Timestamp | Last modification time | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. The globally unique error identifier, for example, SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field. Default is null | 0.6 |
| opaque | LinkedHashMap | Reserved field. Default is null | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if no root error exists | 0.6 |
SDK Examples
Java
SDK
CreateMetricTemplateAction action = new CreateMetricTemplateAction();
action.receiverUuid = "7c10e325f9e232e489062a190cc1dc2a";
action.template = "{ "metricName":"${METRIC_NAME}",
"regionId":"cn-shanghai",
"instanceId":"${RESOURCE_UUID}",
"resource":"vm/${RESOURCE_NAME}",
"dimensions":{
"instanceId":"${METRIC_LABLES.get('VMUuid')}",
"device":"${METRIC_LABLES.get('DiskDeviceLetter')}"
},
"value":${METRIC_VALUE},
"ts":${METRIC_TIME}
}";
action.namespace = "ZStack/VM";
action.metricName = "DiskReadOps";
action.labelsJsonStr = "['VMUuid=95e5885772de4f2bb3e05eba98a43cd0']";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateMetricTemplateAction.Result res = action.call();Python
SDK
CreateMetricTemplateAction action = CreateMetricTemplateAction()
action.receiverUuid = "7c10e325f9e232e489062a190cc1dc2a"
action.template = "{ "metricName":"${METRIC_NAME}",
"regionId":"cn-shanghai",
"instanceId":"${RESOURCE_UUID}",
"resource":"vm/${RESOURCE_NAME}",
"dimensions":{
"instanceId":"${METRIC_LABLES.get('VMUuid')}",
"device":"${METRIC_LABLES.get('DiskDeviceLetter')}"
},
"value":${METRIC_VALUE},
"ts":${METRIC_TIME}
}"
action.namespace = "ZStack/VM"
action.metricName = "DiskReadOps"
action.labelsJsonStr = "['VMUuid=95e5885772de4f2bb3e05eba98a43cd0']"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateMetricTemplateAction.Result res = action.call()DeleteMetricTemplate
API Request
URLs
DELETE zstack/v1/zwatch/metrics/httpreceivers/templates/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers/templates/0187f2f1cfc83e638f306f9af28b3fb5Parameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource. Uniquely identifies the resource. | 0.6 | |
| deleteMode (Optional) | String | body | The delete mode (Permissive / Enforcing, default: Permissive). | 0.6 | |
| systemTags (Optional) | List | body | System tags. | 0.6 | |
| userTags (Optional) | List | body | User tags. | 0.6 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains an error field. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
Java
SDK
DeleteMetricTemplateAction action = new DeleteMetricTemplateAction();
action.uuid = "0187f2f1cfc83e638f306f9af28b3fb5";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteMetricTemplateAction.Result res = action.call();Python
SDK
DeleteMetricTemplateAction action = DeleteMetricTemplateAction()
action.uuid = "0187f2f1cfc83e638f306f9af28b3fb5"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteMetricTemplateAction.Result res = action.call()QueryMetricTemplate
API Request
URLs
GET zstack/v1/zwatch/metrics/httpreceivers/templates
GET zstack/v1/zwatch/metrics/httpreceivers/templates/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers/templates?q=receiverUuid=13213154f64e33bb8ad461956981a6e2curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/metrics/httpreceivers/templates/98a42f1af96e3c89b59e87bb20cc6421Queryable Fields
Run the CLI command-line tool, enter QueryMetricTemplate, and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
Response Example
{
"inventories": [
{
"uuid": "77fa620b8d36311ca413c1bfc661c207",
"name": "CloudMonitor",
"url": "http://127.0.0.1/xxx",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"state": "Enabled"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | Whether the operation succeeded. | 0.6 |
| inventories | List | See inventories for details. | 0.6 |
| error | ErrorCode | The error code. If not null, the operation failed. This field is null when the operation succeeds. See error for details. | 0.6 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource. Uniquely identifies the resource. | 0.6 |
| name | String | The resource name. | 0.6 |
| url | String | The URL. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| createDate | Timestamp | The creation time. | 0.6 |
| lastOpDate | Timestamp | The last modification time. | 0.6 |
| state | ReceiverState | See state for details. | 0.6 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Enabled | ReceiverState | Whether the resource is enabled. | 0.6 |
| Disabled | ReceiverState | The Disabled value. | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001. | 0.6 |
| description | String | A brief description of the error. | 0.6 |
| details | String | The detailed error information. | 0.6 |
| elaboration | String | A reserved field. Default is null. | 0.6 |
| opaque | LinkedHashMap | A reserved field. Default is null. | 0.6 |
| cause | ErrorCode | The root error. The source error that caused the current error. This field is null if there is no root cause. | 0.6 |
SDK Examples
Java
SDK
QueryMetricTemplateAction action = new QueryMetricTemplateAction();
action.conditions = asList("receiverUuid=21eee98608ce3cc580d7572e6ee47fea");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryMetricTemplateAction.Result res = action.call();Python
SDK
QueryMetricTemplateAction action = QueryMetricTemplateAction()
action.conditions = ["receiverUuid=aca6437c53a4348eb6d8c20fe0cf054e"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryMetricTemplateAction.Result res = action.call()