Repository navigation
Expand file tree
/
Copy pathbuild.js
More file actions
76 lines (64 loc) · 1.86 KB
/
Copy pathbuild.js
File metadata and controls
76 lines (64 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var fs = require("fs");
const DashboardBuilder = require("./src/lib/DashboardBuilder");
const { exit } = require("process");
const builder = new DashboardBuilder()
const options = {
table: "webperf_rum_events",
datasourceUid: "BRUMMUCSTARBUCS",
filterMap: {},
}
const buildDir = "./build";
try {
if(fs.existsSync(buildDir)) {
fs.rmSync(buildDir, { recursive: true, force: true });
console.log("Removed the build folder.");
}
} catch(e) {
console.error(e);
exit(1);
}
if (!fs.existsSync(buildDir)){
fs.mkdirSync(buildDir);
console.log("Created build folder.");
}
const dashboardsDir = "./build/dashboards";
if (!fs.existsSync(dashboardsDir)){
fs.mkdirSync(dashboardsDir);
console.log("Created build/dashboards folder.");
}
const datasourcesDir = "./build/datasources";
if (!fs.existsSync(datasourcesDir)){
fs.mkdirSync(datasourcesDir);
console.log("Created build/datasources folder.");
}
try {
fs.copyFileSync("./templates/dashboards/General.yaml", "./build/dashboards/General.yaml");
console.log("Added build/dashboards/General.yaml");
} catch(e) {
console.error(e);
exit(1);
}
try {
fs.copyFileSync("./templates/datasources/default.yaml", "./build/datasources/default.yaml");
console.log("Added build/datasources/default.yaml");
} catch(e) {
console.error(e);
exit(1);
}
const dashboards = ["General", "Metrics", "Summary"];
var summaryList = [];
for (const dashboard of dashboards) {
var summary = builder.build(dashboard, options);
summaryList.push(summary);
}
console.log("");
console.log("SUMMARY");
console.log("");
console.log("dashboards: " + summaryList.length);
console.log("");
for (const summary of summaryList) {
console.log("dashboard: " + summary.name);
console.log("panels: " + summary.panels);
console.log("path: " + summary.path);
console.log("");
}