Get Object’s Metrics History
Returns object’s history of metrics.
Request
Path parameters
Parameters | Type | Description |
---|---|---|
id |
String |
The ID or discovery ID of the object whose metrics history must be retrieved. |
Query parameters
Parameter | Type | Description |
---|---|---|
metrics |
String |
A comma-separated list of metrics to be retrieved. |
from |
String |
A lower-bound timestamp of metrics' values. |
downsample |
String |
A down-sampling parameter. For example, |
timezone |
String |
A timezone of metrics' values. For example, |
to |
String |
An upper-bound timestamp of metrics' values. If not specified, considered equal to your current local time. |
Response
Returns an array of requested metrics. Each metric contains the following fields:
Field | Type | Description |
---|---|---|
metric |
String |
Metric name. |
tags.entity |
String |
The ID of the entity prefixed by the type of the entity. The format is |
aggregateTags |
Array |
|
dps |
Array<DataPoint> |
An array of data points. Each data point is represented by an array that contains two values. The first one is a timestamp, the second one is value. |
To get all available metrics for an object, use the Get Object Stat Metrics method. |
Example
Request
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
login=<...>
password=<...>
saymon_hostname=<...>
object_id=<...>
url=https://$saymon_hostname/node/api/objects/$object_id/history
curl -X GET $url -u $login:$password -G \
--data-urlencode "metrics=percentageUsage.combined" \
--data-urlencode "from=1580029200000" \
--data-urlencode "to=1580115600000" \
--data-urlencode "downsample=1h-avg"
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let queryParams =
"metrics=percentageUsage.combined" + "&" +
"from=1580029200000" + "&" +
"to=1580115600000" + "&" +
"downsample=1h-avg";
let path = "/node/api/objects/" + objectId + "/history" + "?" + queryParams;
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Authorization", auth);
let requestOptions = {
method: "GET",
headers: headers
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
const querystring = require("querystring");
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let queryParams = querystring.stringify({
metrics : "percentageUsage.combined",
from : "1580029200000",
to : "1580115600000",
downsample: "1h-avg"
});
let path = "/node/api/objects/" + objectId + "/history" + "?" + queryParams;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "GET",
"hostname": saymonHostname,
"headers": {
"Authorization": auth
},
"path": path
};
let req = http.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
object_id = <...>
url = "https://" + saymon_hostname + "/node/api/objects/" + \
object_id + "/history"
params = {
"metrics": "percentageUsage.combined",
"from": "1580029200000",
"to": "1580115600000",
"downsample": "1h-avg"
}
response = requests.request("GET", url, auth=(login, password), params=params)
print(response.text)