Files
logAggregator/index.js

35 lines
854 B
JavaScript
Raw Normal View History

2019-01-02 14:22:10 -06:00
const micro = require('micro')
const {json,send} = require('micro')
2019-01-02 13:17:56 -06:00
const reTest= (regex,data)=>{
let match = regex.match(new RegExp('^/(.*?)/([giumy]*)$'));
regex = new RegExp(match[1], match[2]);
return regex.test(data);
}
// SourceTag
// ProcessingType
2019-01-02 14:22:10 -06:00
const server = micro(async (req,res) => {
//console.log(req);
const js = await json(req);
//console.log("Received Data",js);
2019-01-02 13:17:56 -06:00
try {
2019-01-02 14:22:10 -06:00
inputLine = JSON.parse(js);
2019-01-02 13:17:56 -06:00
} catch (ex) {
console.error("Input not in JSON format:" + line);
}
2019-01-02 14:22:10 -06:00
if (inputLine.processingType==="casrpslog") {
if (inputLine.data.Severity > 1 ) {
console.log("Issue ",inputLine.data.LogText);
}
}
//console.log("line: " + reTest("/error/i",inputLine));
send(res,200,"OK");
});
server.listen(2222);