All Products
Search
Document Center

Query the latest data points in the multi-value data model

Last Updated: May 29, 2020

Request path and method

Request path Request method Description
/api/query/mlast POST Queries the latest data points that are written for the fields. The fields are used to describe the metric in the multi-value data model.

Request parameters

Parameter Type Required Description Default value Example
queries Array Yes The subquery array. N/A For more information about example values, see the subquery description.
timestamp Long No The Unix timestamp, in seconds or milliseconds. If you specify this parameter, the API operation returns the latest data points up to the time specified by this parameter. If you do not specify this parameter, the API operation returns the current latest data points for the tags. This parameter is of the same level as the queries parameter. N/A 1539763573
tupleFormat Boolean No Specifies whether the tuple type is used in the query result to return the latest data points of the fields. For more information, see the sample request. false false
tupleOffset Long No The offset settings for the returned data that is of the tuple data type. The query results are paginated. This parameter takes effect only when the tupleFormat parameter is set to true . 0 5
tupleLimit Long No The maximum number of tuples to return on each page. The query results are paginated. This parameter takes effect only when the tupleFormat parameter is set to true . 0 100

Note: The /api/query/mfast API endpoint applies only to the multi-value data. To query the latest data points of single-value data, you must use the /api/query/last API endpoint.

Subqueries in the JSON format

Parameter Type Required Description Default value Example
metric String Yes The metric for the latest data points to be queried. N/A wind
fields List Yes The fields of the latest data points to be queried. You can use an asterisk (*) to query all fields of the metric. N/A {speed, level, description}
tags String No The tags of the latest data points to be queried. N/A sensor = IOTE_1988_0001

Sample request in the JSON format

In this sample request, you want to query the latest data points that written for the usage_system and usage_idle fields. These two fields are used to describe the cpu metric, and the tag setting is host_name=host1.To query the target data, you must use the POST/api/query/mlast API endpoint.The request body is described as follows:

  1. {
  2. "tupleFormat": true,
  3. "tupleOffset":5,
  4. "tupleLimit":100,
  5. "timestamp" : 1551851846,
  6. "queries": [
  7. {
  8. "metric": "cpu",
  9. "fields": ["usage_system", "usage_idle"],
  10. "tags": {
  11. "host_name": "host1"
  12. }
  13. }
  14. ]
  15. }

Response description

If a query is successful, the HTTP status code is 200, and the latest data points of the timelines that meet the requirements are returned in the JSON format. If no timelines meet the requirements, an empty set is returned. The following table describes the response parameters.

Parameter Description
metric The metric name.
columns The names of columns in the result set, including the timestamps and names of fields that were queried.
tags The tag key-value pairs that correspond to the data points.
values The values of the queried fields. The sequence of values is consistent with that of the columns.

Note: If you set the tupleFormat parameter to false, the response is in the same format as that for the single-value data model. For more information, see the /api/query/last description.

Sample response in the JSON format

  1. [
  2. {
  3. "metric": "wind",
  4. "columns": [
  5. "timestamp",
  6. "level",
  7. "speed"
  8. ],
  9. "tags": {
  10. "city": "hangzhou",
  11. "country": "china",
  12. "province": "zhejiang",
  13. "sensor": "IOTE_8859_0001"
  14. },
  15. "values": [
  16. [1346846405000, 5.1, 45.1]
  17. ]
  18. }
  19. ]