Query Metric Data¶
Query metric data in batches. At most the first 10000 pieces of data sorted by time can be returned.
Before You Start¶
Ensure that the derived metrics, compound metrics, and the query mappings have been created and published.
Using Get Method¶
Request Format¶
GET https://{apigw-address}/metric-mgmt/v1.0/metrics/data/normal
Request Parameters (Header)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
Content-type |
Mandatory |
String |
The content or file types. The value is set to application/json by default. |
Request Parameters (URI)¶
Name |
Location(Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
Mandatory |
String |
The organization ID which the attribute belongs to. How to get orgId >> |
metrics |
Query |
Mandatory |
String |
The metric IDs needs to be queried. Separate multiple metric IDs by commas. |
startTime |
Query |
Optional |
String |
The start time. Format: yyyy-MM-dd HH:mm:ss.
|
endTime |
Query |
Optional |
String |
The end time. Format: yyyy-MM-dd HH:mm:ss.
|
mdmIds |
Query |
Optional |
String |
The device ID. Separate multiple device IDs by commas. If this parameter is null, all of the devices will be queried by default. |
extraFields |
Query |
Optional |
String |
Query the attributes of other dimensions. |
format |
Query |
Optional |
Int |
The return format of the query result.
|
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
List<JSONObject> |
Return metric data. For more information, see Metric Data Format>> |
Metric Data Format ¶
Name |
Data Type |
Description |
---|---|---|
metricIdentifier |
String |
Metric ID |
time |
String |
Time |
mdmId |
String |
Device |
Samples¶
Request Sample¶
url: https://{apigw-address}/metric-mgmt/v1.0/metrics/data/normal?orgId=orgId&metrics=metricId0,metricId1&startTime=2021-05-19 00:00:00&endTime=2021-05-21 00:00:00
method: GET
Return Sample¶
The return sample is as bellow when the value of the request parameter format
is 0
.
{
"msg": "OK",
"code": 0,
"data": [
{
"metricIdentifier":"MetricId0",
"value":[
{
"storage_active_electric": 2200.00,
"time": "2021-05-20",
"mdmId": "mdmId0"
},
{
"storage_active_electric": 100.00,
"time": "2021-05-20",
"mdmId": "mdmId1"
}
]
},
{
"metricIdentifier":"MetricId1",
"value":[
{
"storage_reactive_electric": 2200.00,
"time": "2021-05-20",
"mdmId": "mdmId0"
},
{
"storage_reactive_electric": 100.00,
"time": "2021-05-20",
"mdmId": "mdmId1"
}
]
}
]
}
The return sample is as bellow when the value of the request parameter format
is 1
.
{
"msg": "OK",
"code": 0,
"data": [
{
"metricIdentifier": "MetricId0",
"mdmId": "mdmId0",
"value": [
{
"storage_active_electric": 2200.00,
"time": "2021-05-20"
},
{
"storage_active_electric": 100.00,
"time": "2021-05-20"
}
]
},
{
"metricIdentifier": "MetricId0",
"mdmId": "mdmId1",
"value": [
{
"storage_active_electric": 2200.00,
"time": "2021-05-20"
},
{
"storage_active_electric": 100.00,
"time": "2021-05-20"
}
]
},
{
"metricIdentifier": "MetricId1",
"mdmId": "mdmId0",
"value": [
{
"storage_reactive_electric": 2200.00,
"time": "2021-05-20"
},
{
"storage_reactive_electric": 100.00,
"time": "2021-05-20",
}
]
},
{
"metricIdentifier": "MetricId1",
"mdmId": "mdmId1",
"value": [
{
"storage_reactive_electric": 2200.00,
"time": "2021-05-20"
},
{
"storage_reactive_electric": 100.00,
"time": "2021-05-20"
}
]
}
]
}
The return sample is as bellow when the value of the request parameter format
is 2
.
{
"msg": "OK",
"code": 0,
"data": [
{
"mdmId": "mdmId0",
"value":[
{
"MetricId0": 2200.00,
"MetricId1": 2200.00,
"time": "2021-05-20"
},
{
"MetricId0": 100.00,
"MetricId1": 100.00,
"time": "2021-05-21"
}
]
},
{
"mdmId": "mdmId1",
"value":[
{
"MetricId0": 2200.00,
"MetricId1": 2200.00,
"time": "2021-05-20"
},
{
"MetricId0": 100.00,
"MetricId1": 100.00,
"time": "2021-05-21"
}
]
}
]
}
SDK Sample¶
You can access the SDK samples for metric management service on GitHub:
Using POST Method¶
Request Format¶
POST https://{apigw-address}/metric-mgmt/v1.0/metrics/data/normal
Request Parameters (Header)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
Content-type |
Mandatory |
String |
The content or file types. The value is set to application/json by default. |
Request Parameters (URI)¶
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
List<JSONObject> |
Return metric data. For more information, see Metric Data Format>> |
Metric Data Format¶
Name |
Data Type |
Description |
---|---|---|
metricIdentifier |
String |
Metric ID |
time |
String |
Time |
mdmId |
String |
Device |
Samples¶
Request Sample¶
url: http://{apigw-address}/metric-mgmt/v1.0/metrics/data/normal?orgId=orgId
method: POST
request body:
{
"orgId": "orgId of metric",
"metrics": "metricId",
"mdmIds": "mdmId",
"startTime": "2022-01-19 14:18:07",
"endTime": "2022-01-20 14:18:07",
"extraFields":"",
"format":0
}
Return Sample¶
See return samples of Get method: Return Samples>>
SDK Sample¶
You can access the SDK samples for metric management service on GitHub: