Get Stat History
Returns stat history records for specified entities (objects and links). Records are always sorted by their timestamps in descending order.
Request
HTTP Request
Path parameters
No parameters required.
Body parameters
Parameter | Type | Description |
---|---|---|
ids | Array<String> | An array of entities' ids for which stat history records should be retrieved. The request returns the stat history of only those entities that you have permissions to access. |
from | Integer | A lower-bound timestamp (inclusive) for stat history records. If not specified, considered equal to the timestamp of the last record. |
to | Integer | An upper-bound timestamp (exclusive) for stat history records. If not specified, considered equal to your current local time. |
skip | Integer | The number of the first records to be skipped. This parameter applies after the from and to parameters and used for pagination. It shouldn't be used along with the after parameter. |
limit | Integer | The maximum number of history records in the response. The default value is 10 . |
after | Integer | An upper-bound (excluding) timestamp for stat history records. This parameter is applied after the from and to parameters and used for live scrolling. It shouldn't be used along with the skip parameter. |
exclude | Object | A set of parameters used as a filter for history records. Each parameter should be specified in the following format: "payload.param_name": "value" . The records that fit the filter won't be included in a response. |
include | Object | A set of parameters used as a filter for history records. Each parameter should be specified in the following format: "payload.param_name": "value" . The records that don't fit the filter won't be included in a response. |
Request body
Response
Returns an array of stats for a specified entity. See the Stat model for a list of returned fields.
Example
Request
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/stat-history
curl -X POST $url -u $login:$password \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"ids": [
"5db30e30aec6940219d5f5fa",
"5db2c770aec6940219d5f179"
],
"limit": 20,
"after": 1587743543000,
"include": {
"payload.operation": 0
},
"exclude": {
"payload.inherited": true
}
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/stat-history";
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);
let data = JSON.stringify({
"ids": [
"5db30e30aec6940219d5f5fa",
"5db2c770aec6940219d5f179"
],
"limit": 20,
"after": 1587743543000,
"include": {
"payload.operation": 0
},
"exclude": {
"payload.inherited": true
}
});
let requestOptions = {
method: "POST",
headers: headers,
body: data
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/stat-history";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "POST",
"hostname": saymonHostname,
"path": path,
"headers": {
"Authorization": auth,
"Content-Type": "application/json"
}
};
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);
});
});
let data = JSON.stringify({
"ids": [
"5db30e30aec6940219d5f5fa",
"5db2c770aec6940219d5f179"
],
"limit": 20,
"after": 1587743543000,
"include": {
"payload.operation": 0
},
"exclude": {
"payload.inherited": true
}
});
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/stat-history"
body = {
"ids": [
"5db30e30aec6940219d5f5fa",
"5db2c770aec6940219d5f179"
],
"limit": 20,
"after": 1587743543000,
"include": {
"payload.operation": 0
},
"exclude": {
"payload.inherited": True
}
}
response = requests.request("POST", url, json=body, auth=(login, password))
print(response.text)
Response
[
{
"period": -1,
"payload": {
"operation": 0
},
"entityType": "obj",
"entityId": "5db2c770aec6940219d5f179",
"timestamp": 1577274603993
},
{
"period": -1,
"payload": {
"operation": 0
},
"entityType": "obj",
"entityId": "5db2c770aec6940219d5f179",
"timestamp": 1574855228252
},
{
"period": -1,
"payload": {
"operation": 0
},
"entityType": "obj",
"entityId": "5db2c770aec6940219d5f179",
"timestamp": 1573825706658
},
...
]