Skip to main content

Custom Script Reports

The create custom script report page allows users to generate reports based on custom scripts within the Motadata AIOps platform. This feature enables organizations to extract specific insights and metrics from their IT environment using customized scripts tailored to their unique monitoring requirements. By leveraging custom script reports, users can gain deeper visibility into key performance indicators, troubleshoot issues, and optimize their infrastructure effectively.

With this feature, organizations can develop and deploy scripts tailored to their specific monitoring needs, allowing them to collect, analyze, and visualize data in a way that aligns with their business objectives.

Select the Script Language

Select the Script Language (GO, Python, or Node.js) that you wish you use to create the custom script report.

Write the Reporting Script

Compose the Reporting Script according to your desired report format and data retrieval needs.

Below is an example of a Node.js script designed to showcase CPU Utilization metrics for all network devices within your infrastructure:

  const readline = require("readline/promises");
const fs = require('node:fs');
const rl = readline.createInterface(process.stdin, process.stdout);
const cmdArgs = process.argv;
let reportContext = cmdArgs[cmdArgs.length - 1].replace(/^(--context=)/, "");
reportContext = JSON.parse(reportContext);
const reportDefination = {
...reportContext,
"visualization.name": "CPU & MEMORY UTILIZATION (Network Device)",
"visualization.timeline": {
"relative.timeline": "today",
"visualization.time.range.inclusive": "no"
},
"visualization.category": "Grid",
"visualization.type": "Grid",
"join.type": "any",
"visualization.data.sources": [
{
"type": "metric",
"join.type": "any",
"visualization.result.by": [
"monitor"
],
"filters": {
"data.filter": {

},
"result.filter": {

}
},
"data.points": [
{
"data.point": "system.cpu.percent",
"aggregator": "avg",
"entities": ["Network"],
"entity.type": "category"
},
{
"data.point": "system.cpu.percent",
"aggregator": "min",
"entities": ["Network"],
"entity.type": "category"
},
{
"data.point": "system.cpu.percent",
"aggregator": "max",
"entities": ["Network"],
"entity.type": "category"
},
{
"data.point": "system.memory.used.percent",
"aggregator": "avg",
"entities": ["Network"],
"entity.type": "category"
},
{
"data.point": "system.memory.used.percent",
"aggregator": "min",
"entities": ["Network"],
"entity.type": "category"
},
{
"data.point": "system.memory.used.percent",
"aggregator": "max",
"entities": ["Network"],
"entity.type": "category"
},
{
"data.point": "ping.latency.ms",
"aggregator": "avg",
"entities": ["Network"],
"entity.type": "category"
}
]
},
{
"type": "availability",
"category": "metric",
"visualization.result.by": [
"monitor"
],
"filters": {
"data.filter": {

}
},
"data.points": [
{
"data.point": "monitor.uptime.percent",
"aggregator": "avg",
"entities": ["Network"],
"entity.type": "category"
}
]
}
],
"visualization.properties": {
"grid": {
"searchable": "yes",
"column.selection": "no",
"header": "yes",
"style": {
"header.font.size": "small"
},
"columns": [

]
}
},
"visualization.result.by": [

],
"granularity": {
"value": 5,
"unit": "m"
},
"join.type": "any",
"join.columns": [
"monitor"
],
"container.type": "dashboard",
"_type": "0",
"id": -1
};
let allData = ''
process.stdin.on("data", (data) => {
allData += data;
if (allData.indexOf("_|@#|_") >= 0) {
const formattedData = JSON.stringify(JSON.parse(allData.toString().replace("_|@#|_", '')))
writeOuput(formattedData)
}
});
function writeOuput(output) {
console.log(output + "_|@#|_");
}
(async function main(widget) {
writeOuput(widget);
})(JSON.stringify(reportDefination));

Click the Execute button to view the report generated using the script in the window below the Reporting Script window in which you wrote the script.

Using the above script, you can generate the following report:

By utilizing custom script reports, you can tailor your reports to suit your specific monitoring requirements and extract valuable insights from your IT environment.