Query Latest Metric


Get the latest data of metrics by metric IDs.

Request Format


GET/POST https://{api-gateway}/cds-realtime-service/v1.0/metric/latest?action=query

Request Parameters


Name

Location

Mandatory/Optional

Data Type

Description

orgId

Query

Mandatory

String

The organization ID which the metric belongs to. How to get orgId >>

mdmIds

Query/Form

Mandatory

String

The object instance ID which the metric belongs to. Separate multiple IDs by commas. Up to 20000 object instances are allowed in a single query. To ensure query performance, it is recommended that you pass in no more than 100 object instances in a single query.

metrics

Query/Form

Mandatory

String

The metric ID. Separate multiple IDs by commas. Up to 100 metrics are allowed in a single query. How to get metrics>>

dimensions

Query/Form

Optional

String

The dimension other than asset and time, such as device type and device manufacturer. This parameter is used to aggregate or filter the returned data. Separate multiple dimensions by commas. Up to 10 dimensions are allowed in a single query. How to get dimensions>>

rollup

Query/Form

Optional

Boolean

Whether to roll up data for queries with additional dimensions.

rollupDimensions

Query/Form

Optional

String

The rollup dimensions. If not specified, the value is set to the value of the dimensions parameter.

withDimensionName

Query/Form

Optional

Boolean

Whether to include the dimension name when returning a dimension ID.

locale

Query/Form

Optional

String

Use zh-CN, en-US, ja-JP, or es-ES. If not specified, the value is set to en_US by default.

mdmTypes

Query/Form

Optional

Boolean

Specify how to filter the returned data by the object type that a child asset belongs to. Support specifying only one object type identifier. How to get mdmTypes>>

filter

Query/Form

Optional

String

Specify how to filter the returned data by metrics or dimensions. For example, [[{“field”:”field1”,”operator”:”>=”,”value”:”1”},{“field”:”field2”,”operator”:”<=”,”value”:”2”}],[{“field”:”field3”,”operator”:”==”,”value”:”3”}]], which means the returned data is filtered by (field1 >= 1 and field2 <= 2) or (field3=3).

orderBy

Query/Form

Optional

String

Specify how to sort the returned data by metrics or dimensions. For example, [{“field”:”field1”,”order”:”ASC”}, {“field”:”field2”,”order”:”DESC”}], which means the returned data is sorted first by field1 in ascending order and then by field2 in descending order.

pageSize

Query/Form

Optional

Integer

The number of the returned records on a single page. The maximum number is 20000.

pageNo

Query/Form

Optional

Integer

The number of page to be returned, starting from 1.

Response Content Type


application/json; charset = UTF-8

Response Parameters


Name

To Return Definitely/Conditionally

Data Type

Description

data

Definitely

LatestMetric Struct

Describe the details of the metric. See LatestMetric Struct.

pagination

Definitely

Pagination Struct

Describe the pagination information. See Pagination Struct.

LatestMetric Struct


Name

To Return Definitely/Conditionally

Data Type

Description

metrics

Conditionally

MetricValue Struct

Describe the real-time values of the metric. See MetricValue Struct.

metricsWithDimensions

Conditionally

MetricWithDimension Struct

Describe the real-time values of the metric with dimensions. See MetricWithDimension Struct.

MetricValue Struct


Name

To Return Definitely/Conditionally

Data Type

Description

value

Definitely

Integer/Double/String

The values of the metric.

localtime

Definitely

String

The corresponding data timestamp in local time format.

MetricWithDimension Struct


Name

To Return Definitely/Conditionally

Data Type

Description

dimension

Conditionally

Object

Describe the dimension information of the metric.

metrics

Definitely

MetricValue Struct

Describe the real-time values of the metric. See MetricValue Struct.

Pagination Struct


Name

To Return Definitely/Conditionally

Data Type

Description

pageNo

Definitely

Integer

The number of page to be returned, starting from 1.

pageSize

Definitely

Integer

The number of the returned records on a single page.

totalSize

Definitely

Integer

The total number of the returned records.

Response Codes


See Common Data Service API Response Codes.

Samples

Request Sample


GET https://{api-gateway}/cds-realtime-service/v1.0/metric/latest?action=query&orgId=yourOrgId&mdmIds=yourMdmId&metrics=yourMetrics

Response Sample


{
    "data":{
        "yourMdmId":{
            "metrics":{
                "Production:TD":{
                    "value":0,
                    "localtime":"2021-06-04"
                },
                "Production:MTD":{
                    "value":29,
                    "localtime":"2021-06"
                },
                "Production:YTD":{
                    "value":282720,
                    "localtime":"2021"
                }
            },
            "metricsWithDimensions":[
                {
                    "dimension1":"yourDimension",
                    "metrics":{
                        "Production:TD":{
                            "value":0,
                            "localtime":"2021-06-04"
                        },
                        "Production:MTD":{
                            "value":29,
                            "localtime":"2021-06"
                        },
                        "Production:YTD":{
                            "value":282720,
                            "localtime":"2021"
                        }
                    }
                }
            ]
        }
    },
    "code":0,
    "msg":"OK",
    "traceId": "1234567890abcdefghijkl0987654321"
}