Get Stat History
Request
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 |
limit |
Integer |
The maximum number of history records in the response. The default value is |
after |
Integer |
An upper-bound (excluding) timestamp for stat history records. This parameter is applied after the |
exclude |
Object |
A set of parameters used as a filter for history records. Each parameter should be specified in the following format: |
include |
Object |
A set of parameters used as a filter for history records. Each parameter should be specified in the following format: |
Response
Returns an array of stats for a specified entity. See the Stat model for a list of returned fields.
Example
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
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": 1,
"entityId": "5db2c770aec6940219d5f179",
"timestamp": 1577274603993
},
{
"period": -1,
"payload": {
"operation": 0
},
"entityType": 1,
"entityId": "5db2c770aec6940219d5f179",
"timestamp": 1574855228252
},
{
"period": -1,
"payload": {
"operation": 0
},
"entityType": 1,
"entityId": "5db2c770aec6940219d5f179",
"timestamp": 1573825706658
},
...
]