Get Object's Metrics History

GET /node/api/objects/:id/history

Returns object's history of metrics.
Permissions: objectPermissions.

Request parameters

Path parameters

Parameters
Type
Description
id
String
required
The ID of an object whose history should be retrieved.

Query parameters

Parameter
Type
Description
downsample
String optional
A down-sampling parameter. For example, 1m-avg or 1h-avg denote "one minute average" and "one hour average" accordingly.
from
String required
A lower-bound timestamp of metrics' values.
metrics
String
required
A comma-separated list of metrics to be retrieved.
timezone
String optional
A timezone of metrics' values. For example, Europe/Moscow. Use this parameter if a server's timezone doesn't match your local one and you need to get metrics without time shift.
to
String optional
An upper-bound timestamp of metrics' values. If not specified, considered equal to your current local time.

Response description

...
To get metrics available for an objects, use the Get Object Stat Metrics method.

Examples

Request examples

Provided that object_id is an ID of CPU, its average 1-hour load for 24 hours (26.01.20 12.00 PM - 27.01.20 12.00 PM) can be retrieved as follows:
Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
object_id=<...>
5
url=https://$saymon_hostname/node/api/objects/$object_id/history
6
7
curl -X GET $url -u $login:$password -G \
8
--data-urlencode "metrics=percentageUsage.combined" \
9
--data-urlencode "from=1580029200000" \
10
--data-urlencode "to=1580115600000" \
11
--data-urlencode "downsample=1h-avg"
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let objectId = <...>
5
6
let queryParams =
7
"metrics=percentageUsage.combined" + "&" +
8
"from=1580029200000" + "&" +
9
"to=1580115600000" + "&" +
10
"downsample=1h-avg";
11
12
let path = "/node/api/objects/" + objectId + "/history" + "?" + queryParams;
13
14
let auth = "Basic " + btoa(login + ":" + password);
15
16
let headers = new Headers();
17
headers.append("Authorization", auth);
18
19
let requestOptions = {
20
method: "GET",
21
headers: headers
22
};
23
24
fetch(saymonHostname + path, requestOptions)
25
.then(response => response.text())
26
.then(result => console.log(result))
27
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
const querystring = require("querystring");
3
4
let login = <...>
5
let password = <...>
6
let saymonHostname = <...>
7
let objectId = <...>
8
9
let queryParams = querystring.stringify({
10
metrics : "percentageUsage.combined",
11
from : "1580029200000",
12
to : "1580115600000",
13
downsample: "1h-avg"
14
});
15
16
let path = "/node/api/objects/" + objectId + "/history" + "?" + queryParams;
17
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
18
19
let options = {
20
"method": "GET",
21
"hostname": saymonHostname,
22
"headers": {
23
"Authorization": auth
24
},
25
"path": path
26
};
27
28
let req = http.request(options, function (res) {
29
let chunks = [];
30
31
res.on("data", function (chunk) {
32
chunks.push(chunk);
33
});
34
35
res.on("end", function (chunk) {
36
let body = Buffer.concat(chunks);
37
console.log(body.toString());
38
});
39
40
res.on("error", function (error) {
41
console.error(error);
42
});
43
});
44
45
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
object_id = <...>
7
url = "https://" + saymon_hostname + "/node/api/objects/" + \
8
object_id + "/history"
9
10
params = {
11
"metrics": "percentageUsage.combined",
12
"from": "1580029200000",
13
"to": "1580115600000",
14
"downsample": "1h-avg"
15
}
16
17
response = requests.request("GET", url, auth=(login, password), params=params)
18
print(response.text)
Copied!

Response example

1
[
2
{
3
"metric": "percentageUsage.combined",
4
"tags": {
5
"entity": "obj5e7dc67bc50bdc08abbf16ac"
6
},
7
"aggregateTags": [],
8
"dps": [
9
[
10
1585301160000,
11
6.626150080189077
12
],
13
[
14
1585301280000,
15
2.9540481400437635
16
],
17
...
18
]
19
}
20
]
Copied!
Last modified 1yr ago