Generate Excel Chart Report
Returns the chart widgets of the specified entities in an Excel spreadsheet.
Request
Request body
The request body contains a set of charts to include in the report.
[
{
"type": "line-chart",
"entityId": "62e92397b8ff53567ebda32d",
"entityType": 1,
"metric": "{{packetsReceived}}",
"formula": "{{packetsReceived}}",
"from": 1661425032783,
"to": 1661511432783,
"downsample": "1m-avg"
},
{
"type": "line-chart",
"entityId": "630796035253ca424d67343a",
"entityType": 1,
"metric": "{{responseTimeMs}}",
"formula": "{{responseTimeMs}}",
"from": 1661425032784,
"to": 1661511432784,
"downsample": "1m-avg"
}
]
Response
Returns a binary representation of an Excel spreadsheet that includes the requested charts on the first sheet and the data to build them on the second sheet.
Example
Request
As this request returns the XLSX file, you should output it directly to the output file to avoid corrupting it.
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/reports/prop-inventory/excel
curl -X POST $url +
-H "Content-Type: application/json" +
-o report.xlsx +
-d @- <<EOF
[
{
"type": "line-chart",
"entityId": "62e92397b8ff53567ebda32d",
"entityType": 1,
"metric": "{\{packetsReceived}}",
"formula": "{\{packetsReceived}}",
"from": 1661425032783,
"to": 1661511432783,
"downsample": "1m-avg"
}
]
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/prop-inventory/excel";
let headers = new Headers();
headers.append("Content-Type", "application/json");
let data = JSON.stringify([
{
"type": "line-chart",
"entityId": "62e92397b8ff53567ebda32d",
"entityType": 1,
"metric": "{{packetsReceived}}",
"formula": "{{packetsReceived}}",
"from": 1661425032783,
"to": 1661511432783,
"downsample": "1m-avg"
}
]);
let requestOptions = {
method: "POST",
headers: headers,
body: data
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.blob())
.then(blob => {
var file = window.URL.createObjectURL(blob);
window.location.assign(file);
})
.catch(error => console.log("error", error));
const http = require("http");
const fs = require("fs")
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/prop-inventory/excel";
let options = {
"method": "POST",
"hostname": saymonHostname,
"headers": {
"Content-Type": "application/json"
},
"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);
fs.writeFile('report.xlsx', body.toString(), function (err) {
if (err) return console.log(err);
console.log('Saved report.xlsx');
});
});
res.on("error", function (error) {
console.error(error);
});
});
let data = JSON.stringify([
{
"type": "line-chart",
"entityId": "62e92397b8ff53567ebda32d",
"entityType": 1,
"metric": "{{packetsReceived}}",
"formula": "{{packetsReceived}}",
"from": 1661425032783,
"to": 1661511432783,
"downsample": "1m-avg"
}
]);
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "http://" + saymon_hostname + "/node/api/reports/prop-inventory/excel"
json = [
{
"type": "line-chart",
"entityId": "62e92397b8ff53567ebda32d",
"entityType": 1,
"metric": "{{packetsReceived}}",
"formula": "{{packetsReceived}}",
"from": 1661425032783,
"to": 1661511432783,
"downsample": "1m-avg"
}
]
response = requests.request("POST", url, json=json, auth=(login, password))
f = open("report.xlsx", "w")
f.write(response.text)
f.close()