Generate Excel Report of Active Incidents
Returns a list of all active incidents as an Excel spreadsheet.
Request
HTTP Request
Permissions
Path parameters
Parameter | Type | Description |
---|---|---|
fields | Array<String> | The fields that will be included in the report. See the Incident model to see all possible fields. |
filter | Incident Filter | The incident filter. See the list of available filters. |
Request body
The request body is empty.
Response
Returns an Excel spreadsheet with the list of active incidents containing the requested fields. You can specify an incident filter in the path parameters.
Example
This example returns an Excel spreadsheet with active incidents that happened in the time frame, specified in the filter
.
The filter:
Warning
If there are too many entries in the report, the request might return the spreadsheet with the string "504 Gateway Timeout" in it, instead of the expected report. In this case, limit the output with filters.
Request
As this request returns the XLSX file, you should output it directly to the output file to avoid corrupting it.
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/incidents/excel?filter=%5B%22timestamp%22%2C%7B%22from%22%3A1660472869475%2C%22to%22%3A1660904869477%7D%5D";
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 fs = require('fs');
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/incidents/excel?filter=%5B%22timestamp%22%2C%7B%22from%22%3A1660472869475%2C%22to%22%3A1660904869477%7D%5D";
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());
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);
});
});
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/reports/incidents/excel?filter=%5B%22timestamp%22%2C%7B%22from%22%3A1660472869475%2C%22to%22%3A1660904869477%7D%5D"
response = requests.request("GET", url, auth=(login, password))
f = open("report.xlsx", "w")
f.write(response.text)
f.close()
Response
The response contains a binary representation of the Excel table with the list of active incidents:
Registered Time | Occurred Time | Object/Link | Severity | Text | Acknowledged By | Comment |
---|---|---|---|---|---|---|
19.07.2022, 19:57:02 | 19.07.2022, 19:57:02 | object1 | Major | Нет Данных | user.name | |
14.07.2022, 12:19:29 | 14.07.2022, 12:19:29 | link1 | text | |||
19.07.2022, 19:56:33 | 19.07.2022, 19:56:33 | object2 | Warning | Incident Text | user | Incident comment |