Browse Source

redis logs ok

master
lefteris 4 years ago
parent
commit
05fee73724
  1. 55
      swarmlab-app/src/run/app.js

55
swarmlab-app/src/run/app.js

@ -117,19 +117,32 @@ app.get("/length", cors(corsOptions), (req, res) => {
var mongol = 0;
var mongolerror = 0;
var redis = 0;
var dumout = 0;
var dumerr = 0;
obj.forEach((value) => {
if (value.container_name == "/mongo") {
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")) {
} else if (
value.container_name == "/readmongo_service" &&
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++;
} else if (
value.container_name == "/dummy_service" &&
value.log.includes("app_name")
) {
var test = JSON.parse(value.log);
var type = test.type;
if (type == "err") dumerr++;
else dumout++;
}
});
var RES = new Object();
@ -139,6 +152,8 @@ app.get("/length", cors(corsOptions), (req, res) => {
appout: appout,
apperror: apperror,
redis: redis,
dumout: dumout,
dumerr: dumerr,
};
RES.data = data;
@ -171,7 +186,7 @@ app.get("/test", cors(corsOptions), (req, res) => {
obj.forEach((value) => {
if (value.container_name == "/redisserver") {
// jsonfinal.push(JSON.parse(value.log));
jsonfinal.push(value.log);
jsonfinal.push(value);
} else if (value.container_name == "/mongo") {
mongo.push(JSON.parse(value.log));
} else if (value.log.includes("app_name")) {
@ -224,7 +239,35 @@ app.get("/test2", cors(corsOptions), (req, res) => {
tmp.type = '<div class="errtype" >' + tmp.type + "</div>";
}
jsonfinal.push(tmp);
} else if (value.container_name == "/redisserver") {
var tmplog = value;
//timestamp
var time = tmplog.time;
var tmp = {
message: tmplog.log,
timestamp: time,
type: "<div class= 'outtype'>out</div>",
process_id: "Unknown",
app_name: "redis",
};
jsonfinal.push(tmp);
}
// else if (value.container_name == "/mongo") {
// var tmplog = JSON.parse(value.log);
// var msg2 = tmplog.msg;
// //timestam
// var time = tmplog.t;
// time = time.$date;
// var tmp = {
// message: msg2,
// timestamp: time,
// type: "<div class= 'outtype'>out</div>",
// process_id: "Unknown",
// app_name: "Mongo",
// };
// jsonfinal.push(tmp);
// }
});
//console.log("Sending Data: " + jsonfinal);
if (sortname == "type") {
@ -251,6 +294,14 @@ app.get("/test2", cors(corsOptions), (req, res) => {
return b.timestamp.localeCompare(a.timestamp);
}
});
} else if (sortname == "app_name") {
jsonfinal.sort(function (a, b) {
if (sortorder == "asc") {
return a.app_name.localeCompare(b.app_name);
} else {
return b.app_name.localeCompare(a.app_name);
}
});
}
//Pagination
var total = jsonfinal.length;

Loading…
Cancel
Save