In this article
Get Last N Samples from a Timeseries ID
Returns the last N samples from a timeseries corresponding to a metric. The only required parameter for this endpoint is n.
URL
https://{{HOST}}/timeseries/timeseries/{timeseries_id}/lastnsamples
Method
GET
Required IMS Scopes
- Read
- Write
Required ACL Permissions
- owner
- admin
- readwrite
- readonly
Versions Supported
- 2.0 (Default)
- 2.1
URL Path Parameters
| Name | Description | Example | Type |
|---|---|---|---|
| timeseries_id required |
Timeseries ID from which to get samples | GUID | string |
URL Query Parameters
| Name | Description | Example | Type |
|---|---|---|---|
| v optional |
Version of the API to use | v=2.0 | string |
| metric optional |
Metric from which to query the samples | Raw | string |
| n optional |
Number of latest samples to return. Default value is 10 | 10 | integer(int32) |
Request Header Parameters
| Type | Value | Description |
|---|---|---|
| Authentication | Bearer {access_token} required |
Retrieve access token |
| Content-Type | application/json required |
Description |
Example
Request
curl -X GET
'https://{{HOST}}/timeseries/timeseries/5d33771d-d87a-4635-9af9-3998744ae33f/lastnsamples?n=1'
-H 'Authorization: Bearer {access_token}'
-H 'Cache-Control: no-cache'
Response
[
{
"timeseriesId": "5d33771d-d87a-4635-9af9-3998744ae33f",
"unixTimestamp": 1487968800000,
"ingestUnixTimestamp": 1488090243352,
"timestamp": "2017-02-24T20:40:00+00:00",
"textTimestamp": "2017-02-24T20:40:00+00:00",
"val": 12,
"metric": "Raw",
"customData" :
{
"reliability": 2
}
}
]
Errors
| Error | Description |
|---|---|
| 200 | Success |
| 204 | Returns 204 samples inserted into persistent store |
| 403 | Forbidden |
Response Body Parameters
| Name | Description | Schema |
|---|---|---|
| timeseriesId | Timeseries the TSElement belogs to | string |
| metric | Metric of the sample | string |
| timestamp | Timestamp of the sample | string(date-time) |
| val | Value of the sample | object |
| unixTimestamp | Unix timestamp of the sample | integer(int64) |
| ingestUnixTimestamp | Unix timestamp the sample was saved to the database | integer(int64) |
| customData | Application specific data can be stored here | Dictionary<string,object> |