|
|
@ -61,6 +61,7 @@ const helmet = require("helmet"); |
|
|
|
app.use(helmet()); |
|
|
|
|
|
|
|
const cors = require("cors"); |
|
|
|
const { MongoError } = require("mongodb"); |
|
|
|
const whitelist = [ |
|
|
|
"http://localhost:3000", |
|
|
|
"http://localhost:8080", |
|
|
@ -114,21 +115,30 @@ app.get("/length", cors(corsOptions), (req, res) => { |
|
|
|
var appout = 0; |
|
|
|
var apperror = 0; |
|
|
|
var mongol = 0; |
|
|
|
var mongolerror = 0; |
|
|
|
var redis = 0; |
|
|
|
obj.forEach((value) => { |
|
|
|
if (value.container_name == "/mongo") { |
|
|
|
mongol++; |
|
|
|
var tmp = JSON.parse(value.log); |
|
|
|
if (tmp.s == "I") mongol++; |
|
|
|
// count every informative log as an output log
|
|
|
|
else if (tmp.s == "W" || tmp.s == "E") mongolerror++; //count every warning and error log
|
|
|
|
} else if (value.log.includes("app_name")) { |
|
|
|
var test = JSON.parse(value.log); |
|
|
|
var type = test.type; |
|
|
|
if (type == "err") apperror++; |
|
|
|
else appout++; |
|
|
|
} else if (value.container_name == "/redisserver") { |
|
|
|
redis++; |
|
|
|
} |
|
|
|
}); |
|
|
|
var RES = new Object(); |
|
|
|
var data = { |
|
|
|
mongolength: mongol, |
|
|
|
mongolerror: mongolerror, |
|
|
|
appout: appout, |
|
|
|
apperror: apperror, |
|
|
|
redis: redis, |
|
|
|
}; |
|
|
|
RES.data = data; |
|
|
|
|
|
|
@ -156,12 +166,25 @@ app.get("/test", cors(corsOptions), (req, res) => { |
|
|
|
// EPIDI EXW NESTED JSON PREPEI NA TO KANW PARSE DUO FORES
|
|
|
|
var obj = JSON.parse(JSON.stringify(result)); |
|
|
|
var jsonfinal = []; |
|
|
|
var mongo = []; |
|
|
|
var app = []; |
|
|
|
obj.forEach((value) => { |
|
|
|
if (value.container_name == "/mongo") { |
|
|
|
jsonfinal.push(JSON.parse(value.log)); |
|
|
|
if (value.container_name == "/redisserver") { |
|
|
|
// jsonfinal.push(JSON.parse(value.log));
|
|
|
|
jsonfinal.push(value.log); |
|
|
|
} else if (value.container_name == "/mongo") { |
|
|
|
mongo.push(JSON.parse(value.log)); |
|
|
|
} else if (value.log.includes("app_name")) { |
|
|
|
app.push(JSON.parse(value.log)); |
|
|
|
} |
|
|
|
}); |
|
|
|
res.json(jsonfinal); |
|
|
|
var RES = new Object(); |
|
|
|
RES.data = { |
|
|
|
redis: jsonfinal, |
|
|
|
mongo: mongo, |
|
|
|
app: app, |
|
|
|
}; |
|
|
|
res.json(RES.data); |
|
|
|
db.close(); |
|
|
|
}); |
|
|
|
}); |
|
|
|