Request path and method
Path | Method | Description |
---|---|---|
/api/query/last | POST | Obtains the latest data point written into by the time series |
Note: This port is fully compatible with OpenTSDB protocol.
Request content
Request content in the JSON format
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 |
Subqueries in the JSON format
Metric query
Name | Type | Required | Description | Default value | Example |
---|---|---|---|---|---|
metric | String | Yes | Metric of the latest data point to be queried | None | cpu.usage |
tags | String | No | Tags of the latest data point to be queried | None | host_name=host1 |
TSUID query
Name | Type | Required | Description | Default value | Example |
---|---|---|---|---|---|
tsuid | String | Yes | TSUID of the latest data point to be queried | None | 00005B00005C0000F000005D0000EE00005E0000EF |
Note: The TSUID of the timeline can be queried through /api/search/lookup.
Request JSON example
Job: Query the latest data point written into by the time series, of which the metric is “cpu.usage” and the tag is “host_name=host1”. Meanwhile, query the latest data point written into by the two time series, of which TSUIDs are 00005B00005C00002E00005D0000EE00005E0000EF
and 00005B00005C0000F000005D0000EE00005E0000EF
respectively.
Request: POST/api/query/last
Body:
{
"queries" : [
{
"metric":"cpu.usage",
"tags" : {
"host_name": "host1"
}
},
{
"tsuids": [
"00005B00005C00002E00005D0000EE00005E0000EF",
"00005B00005C0000F000005D0000EE00005E0000EF"
]
}
]
}
Response description
After the successful query, HTTP response code 200 is returned. The latest data points of the compliant timeline, in JSON format, are returned. If no timeline meets the condition, an empty set is returned. The JSON object is described as follows:
Name | Description |
---|---|
metric | metric name |
timestamp | The timestamp of the latest data point. |
value | The value of the metric. |
tags | The tag key and value set of the data point. |
tsuid | The ID of the timeline corresponding to the data point. |
Response body:
[{
"metric": "cpu.usage ",
"timestamp": 1556418300000
"value": 30.3
"tags ": {
"host_name": "host1"
},
"tsuid": "00005B00005C00001D ",
}, {
"metric": "cpu.usage ",
"timestamp": 1556418300000
"value": 25.6
"tags ": {
"host_name": "host2",
"cluster": "cluster1"
"zone": "zone1"
},
"tsuid": "00005B00005C00002E00005D0000EE00005E0000EFE ",
}, {
"metric": "cpu.usage ",
"timestamp": 1556418300000
"value": 43.1
"tags ": {
"host_name": "host3",
"cluster": "cluster1"
"zone": "zone1"
},
"tsuid": "00005B00005C0000F000005D0000EE00005E0000EF ",
}]