Generate Excel Report of Incident History

Returns incident history as an Excel spreadsheet.

Request

HTTP Request

GET /node/api/reports/incident-history/excel

Permissions

objectPermissions

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 the Excel spreadsheet with the incident history. 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:

[
    "timestamp",{
        "from": 1660472869475,
        "to": 1660904869477
    }
]
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.

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=http://$saymon_hostname/node/api/reports/incident-history/excel?filter=%5B%22timestamp%22%2C%7B%22from%22%3A1660472869475%2C%22to%22%3A1660904869477%7D%5D

curl -X GET $url -u $login:$password -o report.xlsx
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/incident-history/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.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/incident-history/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);
....

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/incident-history/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 incident history:

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