Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
ef9cb193d5 | |||
9f706e0a70 | |||
b2d4b82532 | |||
63713f4cd2 | |||
5d3bc13126 | |||
4b30234cb6 | |||
271971a373 | |||
d636dab664 | |||
5f94db8d5d | |||
f9866076ca | |||
aa43a221a0 | |||
cb63b305ad | |||
6fde0544f5 | |||
6ed2b6e993 | |||
4f1df305ed | |||
44fccc252e | |||
0854207a04 | |||
64b71dfb42 | |||
d846b100d2 | |||
cb4cfaca09 | |||
3232114c5b | |||
edd3b4d156 |
@ -37,18 +37,6 @@ snyk:
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
@ -135,13 +123,3 @@ pages:
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
allow_failure: true
|
||||
|
4
.snyk
Normal file
4
.snyk
Normal file
@ -0,0 +1,4 @@
|
||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||
version: v1.12.0
|
||||
ignore: {}
|
||||
patch: {}
|
31
dist/elasticlog.classes.elasticlog.d.ts
vendored
31
dist/elasticlog.classes.elasticlog.d.ts
vendored
@ -1,31 +0,0 @@
|
||||
import { Client as ElasticClient } from 'elasticsearch';
|
||||
import { ILogContext } from 'smartlog-interfaces';
|
||||
import { LogScheduler } from './elasticlog.classes.logscheduler';
|
||||
export interface IStandardLogParams {
|
||||
message: string;
|
||||
severity: string;
|
||||
}
|
||||
export interface IElasticLogConstructorOptions {
|
||||
port: number;
|
||||
domain: string;
|
||||
ssl: boolean;
|
||||
user?: string;
|
||||
pass?: string;
|
||||
logContext: ILogContext;
|
||||
}
|
||||
export declare class ElasticLog<T> {
|
||||
client: ElasticClient;
|
||||
logContext: ILogContext;
|
||||
logScheduler: LogScheduler;
|
||||
/**
|
||||
* sets up an instance of Elastic log
|
||||
* @param optionsArg
|
||||
*/
|
||||
constructor(optionsArg: IElasticLogConstructorOptions);
|
||||
/**
|
||||
* computes the host string from the constructor options
|
||||
* @param optionsArg
|
||||
*/
|
||||
private computeHostString(optionsArg);
|
||||
log(logObject: IStandardLogParams, scheduleOverwrite?: boolean): Promise<void>;
|
||||
}
|
77
dist/elasticlog.classes.elasticlog.js
vendored
77
dist/elasticlog.classes.elasticlog.js
vendored
@ -1,77 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// interfaces
|
||||
const elasticsearch_1 = require("elasticsearch");
|
||||
// other classes
|
||||
const elasticlog_classes_logscheduler_1 = require("./elasticlog.classes.logscheduler");
|
||||
class ElasticLog {
|
||||
/**
|
||||
* sets up an instance of Elastic log
|
||||
* @param optionsArg
|
||||
*/
|
||||
constructor(optionsArg) {
|
||||
this.logScheduler = new elasticlog_classes_logscheduler_1.LogScheduler(this);
|
||||
this.logContext = optionsArg.logContext;
|
||||
this.client = new elasticsearch_1.Client({
|
||||
host: this.computeHostString(optionsArg),
|
||||
log: 'trace'
|
||||
});
|
||||
}
|
||||
/**
|
||||
* computes the host string from the constructor options
|
||||
* @param optionsArg
|
||||
*/
|
||||
computeHostString(optionsArg) {
|
||||
let hostString = `${optionsArg.domain}:${optionsArg.port}`;
|
||||
if (optionsArg.user && optionsArg.pass) {
|
||||
hostString = `${optionsArg.user}:${optionsArg.pass}@${hostString}`;
|
||||
}
|
||||
if (optionsArg.ssl) {
|
||||
hostString = `https://${hostString}`;
|
||||
}
|
||||
else {
|
||||
hostString = `http://${hostString}`;
|
||||
}
|
||||
return hostString;
|
||||
}
|
||||
log(logObject, scheduleOverwrite = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const now = new Date();
|
||||
if (this.logScheduler.logsScheduled && !scheduleOverwrite) {
|
||||
this.logScheduler.scheduleLog(logObject);
|
||||
return;
|
||||
}
|
||||
this.client.index({
|
||||
index: `logs-${now.getFullYear()}.${('0' + (now.getMonth() + 1)).slice(-2)}.${now.getDate()}`,
|
||||
type: 'log',
|
||||
body: {
|
||||
'@timestamp': now.toISOString(),
|
||||
zone: this.logContext.zone,
|
||||
container: this.logContext.containerName,
|
||||
environment: this.logContext.environment,
|
||||
severity: logObject.severity,
|
||||
message: logObject.message
|
||||
}
|
||||
}, (error, response) => {
|
||||
if (error) {
|
||||
console.log('ElasticLog encountered an error:');
|
||||
console.log(error);
|
||||
this.logScheduler.addFailedLog(logObject);
|
||||
}
|
||||
else {
|
||||
console.log(`ElasticLog: ${logObject.message}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ElasticLog = ElasticLog;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWxhc3RpY2xvZy5jbGFzc2VzLmVsYXN0aWNsb2cuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9lbGFzdGljbG9nLmNsYXNzZXMuZWxhc3RpY2xvZy50cyJdLC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QkFDbEIsRUFBRSxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztvQkFDVixPQUFPLENBQUMsR0FBRyxDQUFDLGtDQUFrQyxDQUFDLENBQUM7b0JBQ2hELE9BQU8sQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLENBQUM7b0JBQ25CLElBQUksQ0FBQyxZQUFZLENBQUMsWUFBWSxDQUFDLFNBQVMsQ0FBQyxDQUFDO2dCQUM1QyxDQUFDO2dCQUFDLElBQUksQ0FBQyxDQUFDO29CQUNOLE9BQU8sQ0FBQyxHQUFHLENBQUMsZUFBZSxTQUFTLENBQUMsT0FBTyxFQUFFLENBQUMsQ0FBQztnQkFDbEQsQ0FBQztZQUNILENBQUMsQ0FDRixDQUFDO1FBQ0osQ0FBQztLQUFBO0NBQ0Y7QUFsRUQsZ0NBa0VDIn0=
|
11
dist/elasticlog.classes.logscheduler.d.ts
vendored
11
dist/elasticlog.classes.logscheduler.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
import { ElasticLog, IStandardLogParams } from './elasticlog.classes.elasticlog';
|
||||
export declare class LogScheduler {
|
||||
elasticLogRef: ElasticLog<any>;
|
||||
logsScheduled: boolean;
|
||||
logStorage: any[];
|
||||
constructor(elasticLogRefArg: ElasticLog<any>);
|
||||
addFailedLog(objectArg: any | IStandardLogParams): void;
|
||||
scheduleLog(logObject: any): void;
|
||||
setRetry(): void;
|
||||
deferSend(): void;
|
||||
}
|
42
dist/elasticlog.classes.logscheduler.js
vendored
42
dist/elasticlog.classes.logscheduler.js
vendored
@ -1,42 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class LogScheduler {
|
||||
constructor(elasticLogRefArg) {
|
||||
this.logsScheduled = false;
|
||||
this.logStorage = [];
|
||||
this.elasticLogRef = elasticLogRefArg;
|
||||
}
|
||||
addFailedLog(objectArg) {
|
||||
this.logStorage.push(objectArg);
|
||||
this.setRetry();
|
||||
}
|
||||
scheduleLog(logObject) {
|
||||
this.logStorage.push(logObject);
|
||||
}
|
||||
setRetry() {
|
||||
setTimeout(() => {
|
||||
const oldStorage = this.logStorage;
|
||||
this.logStorage = [];
|
||||
for (let logObject of oldStorage) {
|
||||
this.elasticLogRef.log(logObject, true);
|
||||
}
|
||||
if (this.logStorage.length === 0) {
|
||||
console.log('ElasticLog retry success!!!');
|
||||
this.logsScheduled = false;
|
||||
}
|
||||
else {
|
||||
console.log('ElasticLog retry failed');
|
||||
this.setRetry();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
deferSend() {
|
||||
if (!this.logsScheduled) {
|
||||
console.log('Retry ElasticLog in 5 seconds!');
|
||||
this.logsScheduled = true;
|
||||
this.setRetry();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.LogScheduler = LogScheduler;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWxhc3RpY2xvZy5jbGFzc2VzLmxvZ3NjaGVkdWxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2VsYXN0aWNsb2cuY2xhc3Nlcy5sb2dzY2hlZHVsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFFQTtJQUtFLFlBQVksZ0JBQWlDO1FBSDdDLGtCQUFhLEdBQUcsS0FBSyxDQUFDO1FBQ3RCLGVBQVUsR0FBVSxFQUFFLENBQUM7UUFHckIsSUFBSSxDQUFDLGFBQWEsR0FBRyxnQkFBZ0IsQ0FBQztJQUN4QyxDQUFDO0lBRUQsWUFBWSxDQUFDLFNBQW1DO1FBQzlDLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ2hDLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztJQUNsQixDQUFDO0lBQ0QsV0FBVyxDQUFDLFNBQWM7UUFDeEIsSUFBSSxDQUFDLFVBQVUsQ0FBQy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FBQztDQUNGO0FBekNELG9DQXlDQyJ9
|
4
dist/elasticlog.plugins.d.ts
vendored
4
dist/elasticlog.plugins.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import * as elasticsearch from 'elasticsearch';
|
||||
import * as smartdelay from 'smartdelay';
|
||||
import * as smartlogInterfaces from 'smartlog-interfaces';
|
||||
export { elasticsearch, smartdelay, smartlogInterfaces };
|
9
dist/elasticlog.plugins.js
vendored
9
dist/elasticlog.plugins.js
vendored
@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const elasticsearch = require("elasticsearch");
|
||||
exports.elasticsearch = elasticsearch;
|
||||
const smartdelay = require("smartdelay");
|
||||
exports.smartdelay = smartdelay;
|
||||
const smartlogInterfaces = require("smartlog-interfaces");
|
||||
exports.smartlogInterfaces = smartlogInterfaces;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWxhc3RpY2xvZy5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZWxhc3RpY2xvZy5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBR3RDLHNDQUFhO0FBRnRCLHlDQUF5QztBQUVqQixnQ0FBVTtBQURsQywwREFBMEQ7QUFDdEIsZ0RBQWtCIn0=
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export * from './elasticlog.classes.elasticlog';
|
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./elasticlog.classes.elasticlog"));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHFEQUFnRCJ9
|
228
package-lock.json
generated
228
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/elasticlog",
|
||||
"version": "1.0.12",
|
||||
"name": "@mojoio/elasticsearch",
|
||||
"version": "1.0.24",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -74,6 +74,37 @@
|
||||
"@pushrocks/smartpromise": "^2.0.5"
|
||||
}
|
||||
},
|
||||
"@pushrocks/lik": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/lik/-/lik-3.0.2.tgz",
|
||||
"integrity": "sha512-E2kI0jmPBGVfvXpmGEZOiv7amZrAIBpI49WL/gIdMy9MVeo6+k2VLDvYtdjzayVviE+LEt3//Xe08xE74FbP1A==",
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.2",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartrx": "^2.0.2",
|
||||
"@pushrocks/smarttime": "^3.0.5",
|
||||
"@types/minimatch": "^3.0.3",
|
||||
"minimatch": "^3.0.4",
|
||||
"symbol-tree": "^3.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smarttime": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smarttime/-/smarttime-3.0.5.tgz",
|
||||
"integrity": "sha512-nHjJ8xRZ87OE8tBBIAOgjHJmJrc3MaPZtEZ5JDY2U9gjaED6JdRcdQ+vhSaLJT+U2u8YzXOuA6LfNN+X4jZm6A==",
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/luxon": "^1.4.1",
|
||||
"luxon": "^1.8.0"
|
||||
}
|
||||
},
|
||||
"luxon": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/luxon/-/luxon-1.8.0.tgz",
|
||||
"integrity": "sha512-F742cYUYB7X+LXY3cIn6THZUBqRBjeAvF+CWE2i3+eKcv2bzsCsnRsBYL8Qrqzp1dfs6HsVcSjfKt2RcrtUElw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@pushrocks/qenv": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/qenv/-/qenv-2.0.2.tgz",
|
||||
@ -137,12 +168,20 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartlog-interfaces": "^1.0.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartlog-interfaces": {
|
||||
"version": "1.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-1.0.15.tgz",
|
||||
"integrity": "sha512-dn9a+IhneukhtVGQG031oodOITmmQ5s5hcMThd+cMUQL3XYTbLPnZVuJfTDeWCT0iqLqrBD/qp2d1RRc3W/qIQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartlog-interfaces": {
|
||||
"version": "1.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-1.0.15.tgz",
|
||||
"integrity": "sha512-dn9a+IhneukhtVGQG031oodOITmmQ5s5hcMThd+cMUQL3XYTbLPnZVuJfTDeWCT0iqLqrBD/qp2d1RRc3W/qIQ=="
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-2.0.2.tgz",
|
||||
"integrity": "sha512-kJNQ/6kfljgtwebhoiD8WtRWfdVhOoE1nr8FoUJLlOjLphU8SPa42Hg6/yPkSTaGxWwDhk6PkMJl64O7HNjRUQ=="
|
||||
},
|
||||
"@pushrocks/smartpath": {
|
||||
"version": "4.0.1",
|
||||
@ -166,6 +205,17 @@
|
||||
"form-data": "^2.3.2"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartrx": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartrx/-/smartrx-2.0.2.tgz",
|
||||
"integrity": "sha512-3lQONWp/Q/al8O6Cm9v6aSamNAzJimGHNFgHBKKmyBOVZaYrvhd6OMgDDicHE6vkYHXNtltXj5q3aIunz+bKwQ==",
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^3.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"rxjs": "^6.3.3",
|
||||
"smartevent": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartshell": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.8.tgz",
|
||||
@ -177,6 +227,16 @@
|
||||
"which": "^1.3.1"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smarttime": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smarttime/-/smarttime-3.0.2.tgz",
|
||||
"integrity": "sha512-tFo2GZDwNa14umK3fNglvj9G/S981TSS1VZAMlIw7z43uMysbbJtjb8qpo625CilxEbi7D+RcyW5PJbCH2Wf6g==",
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/luxon": "^1.4.0",
|
||||
"luxon": "^1.4.3"
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/tapbundle/-/tapbundle-3.0.7.tgz",
|
||||
@ -234,6 +294,16 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/luxon": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-1.4.1.tgz",
|
||||
"integrity": "sha512-mYv/gbkOJ40CDgR8st5sosfFNrJncdlkpdzQSNRdU86UQg3oWWmll4AO/7B8F5FlBC6YrIXqXDSnkoCBqo+uMA=="
|
||||
},
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "10.12.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.2.tgz",
|
||||
@ -320,8 +390,7 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"dev": true
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.3.0",
|
||||
@ -333,7 +402,6 @@
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -460,8 +528,7 @@
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -478,6 +545,14 @@
|
||||
"type-detect": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"define-properties": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
|
||||
"integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
|
||||
"requires": {
|
||||
"object-keys": "^1.0.12"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@ -500,6 +575,28 @@
|
||||
"lodash": "^4.17.10"
|
||||
}
|
||||
},
|
||||
"es-abstract": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
|
||||
"integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
|
||||
"requires": {
|
||||
"es-to-primitive": "^1.1.1",
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.1",
|
||||
"is-callable": "^1.1.3",
|
||||
"is-regex": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"es-to-primitive": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz",
|
||||
"integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==",
|
||||
"requires": {
|
||||
"is-callable": "^1.1.4",
|
||||
"is-date-object": "^1.0.1",
|
||||
"is-symbol": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"es6-error": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
|
||||
@ -558,6 +655,11 @@
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"dev": true
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||
},
|
||||
"get-func-name": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
|
||||
@ -584,6 +686,14 @@
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||
"dev": true
|
||||
},
|
||||
"has": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
@ -598,6 +708,11 @@
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
|
||||
"dev": true
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
|
||||
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q="
|
||||
},
|
||||
"humanize-ms": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
|
||||
@ -622,6 +737,32 @@
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"dev": true
|
||||
},
|
||||
"is-callable": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
|
||||
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA=="
|
||||
},
|
||||
"is-date-object": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
|
||||
},
|
||||
"is-regex": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||
"requires": {
|
||||
"has": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"is-symbol": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz",
|
||||
"integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==",
|
||||
"requires": {
|
||||
"has-symbols": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
@ -689,6 +830,11 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
|
||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
|
||||
},
|
||||
"luxon": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/luxon/-/luxon-1.5.0.tgz",
|
||||
"integrity": "sha512-9IfJ0a5jA3poJSQnamaoOdPG0ulYk1JUI5IYmEdUhUc8dto4t6TVTu+oIM7fpSYy01GwUAA8kGUZMVe7Qx9Y+Q=="
|
||||
},
|
||||
"make-error": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
|
||||
@ -714,7 +860,6 @@
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -753,6 +898,20 @@
|
||||
"integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==",
|
||||
"dev": true
|
||||
},
|
||||
"object-keys": {
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
|
||||
"integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag=="
|
||||
},
|
||||
"object.getownpropertydescriptors": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
|
||||
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2",
|
||||
"es-abstract": "^1.5.1"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
@ -834,6 +993,14 @@
|
||||
"path-parse": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "6.3.3",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
|
||||
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
@ -860,6 +1027,23 @@
|
||||
"chai-string": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"smartevent": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/smartevent/-/smartevent-1.0.1.tgz",
|
||||
"integrity": "sha1-E9K/LPCU698XgT+g1GBB+BejAqo=",
|
||||
"requires": {
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.16"
|
||||
}
|
||||
},
|
||||
"smartq": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.8.tgz",
|
||||
"integrity": "sha512-FURlYW/C3bLeZjJcBVyw7bxCyQoCXiXbLCZcDUKznhXHaLu35c8m33/a2H8CA0rtb82lvzN8dRLnBZAcNMzNHQ==",
|
||||
"requires": {
|
||||
"util.promisify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
@ -932,6 +1116,11 @@
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
|
||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
|
||||
},
|
||||
"symbol-tree": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
||||
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
|
||||
@ -951,8 +1140,7 @@
|
||||
"tslib": {
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
|
||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.11.0",
|
||||
@ -1032,6 +1220,11 @@
|
||||
"integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==",
|
||||
"dev": true
|
||||
},
|
||||
"typings-global": {
|
||||
"version": "1.0.28",
|
||||
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
|
||||
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A=="
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
@ -1044,6 +1237,15 @@
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
|
||||
"dev": true
|
||||
},
|
||||
"util.promisify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
|
||||
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2",
|
||||
"object.getownpropertydescriptors": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"vinyl": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
|
||||
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/elasticlog",
|
||||
"version": "1.0.12",
|
||||
"name": "@mojoio/elasticsearch",
|
||||
"version": "1.0.24",
|
||||
"private": false,
|
||||
"description": "log to elasticsearch in a kibana compatible format",
|
||||
"main": "dist/index.js",
|
||||
@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"format": "(gitzone format)",
|
||||
"build": "echo \"Not needed for now\""
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
@ -23,8 +23,11 @@
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.2",
|
||||
"@pushrocks/smartdelay": "^2.0.2",
|
||||
"@pushrocks/smartlog-interfaces": "^1.0.15",
|
||||
"@pushrocks/smartlog-interfaces": "^2.0.2",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smarttime": "^3.0.2",
|
||||
"@types/elasticsearch": "^5.0.28",
|
||||
"elasticsearch": "^15.2.0"
|
||||
}
|
||||
|
30
test/test.ts
30
test/test.ts
@ -1,31 +1,37 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { Qenv } from '@pushrocks/qenv';
|
||||
import * as elasticlog from '../ts/index';
|
||||
import * as elasticsearch from '../ts/index';
|
||||
|
||||
const testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
let testElasticLog: elasticlog.ElasticLog<any>;
|
||||
let testElasticLog: elasticsearch.ElasticSearch<any>;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
testElasticLog = new elasticlog.ElasticLog({
|
||||
testElasticLog = new elasticsearch.ElasticSearch({
|
||||
indexPrefix: 'smartlog',
|
||||
indexRetention: 7,
|
||||
domain: process.env.ELK_DOMAIN,
|
||||
port: parseInt(process.env.ELK_PORT, 10),
|
||||
ssl: true,
|
||||
user: process.env.ELK_USER,
|
||||
pass: process.env.ELK_PASS,
|
||||
logContext: {
|
||||
company: 'Lossless GmbH',
|
||||
runtime: 'node',
|
||||
containerName: 'testContainer',
|
||||
environment: 'test'
|
||||
}
|
||||
pass: process.env.ELK_PASS
|
||||
});
|
||||
expect(testElasticLog).to.be.instanceOf(elasticlog.ElasticLog);
|
||||
expect(testElasticLog).to.be.instanceOf(elasticsearch.ElasticSearch);
|
||||
});
|
||||
|
||||
tap.test('should send a message to Elasticsearch', async () => {
|
||||
testElasticLog.log({
|
||||
severity: 'log',
|
||||
timestamp: Date.now(),
|
||||
type: 'increment',
|
||||
level: 'info',
|
||||
context: {
|
||||
company: 'Lossless GmbH',
|
||||
companyunit: 'lossless.cloud',
|
||||
containerName: 'testcontainer',
|
||||
environment: 'test',
|
||||
runtime: 'node',
|
||||
zone: 'ship.zone'
|
||||
},
|
||||
message: 'hi, this is a testMessage'
|
||||
});
|
||||
});
|
||||
|
@ -1,88 +0,0 @@
|
||||
// interfaces
|
||||
import { Client as ElasticClient } from 'elasticsearch';
|
||||
import { ILogContext } from '@pushrocks/smartlog-interfaces';
|
||||
|
||||
// other classes
|
||||
import { LogScheduler } from './elasticlog.classes.logscheduler';
|
||||
|
||||
export interface IStandardLogParams {
|
||||
message: string;
|
||||
severity: string;
|
||||
}
|
||||
|
||||
export interface IElasticLogConstructorOptions {
|
||||
port: number;
|
||||
domain: string;
|
||||
ssl: boolean;
|
||||
user?: string;
|
||||
pass?: string;
|
||||
logContext: ILogContext;
|
||||
}
|
||||
|
||||
export class ElasticLog<T> {
|
||||
client: ElasticClient;
|
||||
logContext: ILogContext;
|
||||
logScheduler = new LogScheduler(this);
|
||||
|
||||
/**
|
||||
* sets up an instance of Elastic log
|
||||
* @param optionsArg
|
||||
*/
|
||||
constructor(optionsArg: IElasticLogConstructorOptions) {
|
||||
this.logContext = optionsArg.logContext;
|
||||
this.client = new ElasticClient({
|
||||
host: this.computeHostString(optionsArg),
|
||||
log: 'trace'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* computes the host string from the constructor options
|
||||
* @param optionsArg
|
||||
*/
|
||||
private computeHostString(optionsArg: IElasticLogConstructorOptions): string {
|
||||
let hostString = `${optionsArg.domain}:${optionsArg.port}`;
|
||||
if (optionsArg.user && optionsArg.pass) {
|
||||
hostString = `${optionsArg.user}:${optionsArg.pass}@${hostString}`;
|
||||
}
|
||||
if (optionsArg.ssl) {
|
||||
hostString = `https://${hostString}`;
|
||||
} else {
|
||||
hostString = `http://${hostString}`;
|
||||
}
|
||||
return hostString;
|
||||
}
|
||||
|
||||
async log(logObject: IStandardLogParams, scheduleOverwrite = false) {
|
||||
const now = new Date();
|
||||
if (this.logScheduler.logsScheduled && !scheduleOverwrite) {
|
||||
this.logScheduler.scheduleLog(logObject);
|
||||
return;
|
||||
}
|
||||
this.client.index(
|
||||
{
|
||||
index: `logstash-${now.getFullYear()}.${('0' + (now.getMonth() + 1)).slice(-2)}.${(
|
||||
'0' + now.getDate()
|
||||
).slice(-2)}`,
|
||||
type: 'log',
|
||||
body: {
|
||||
'@timestamp': now.toISOString(),
|
||||
zone: this.logContext.zone,
|
||||
container: this.logContext.containerName,
|
||||
environment: this.logContext.environment,
|
||||
severity: logObject.severity,
|
||||
message: logObject.message
|
||||
}
|
||||
},
|
||||
(error, response) => {
|
||||
if (error) {
|
||||
console.log('ElasticLog encountered an error:');
|
||||
console.log(error);
|
||||
this.logScheduler.addFailedLog(logObject);
|
||||
} else {
|
||||
console.log(`ElasticLog: ${logObject.message}`);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
import { ElasticLog, IStandardLogParams } from './elasticlog.classes.elasticlog';
|
||||
|
||||
export class LogScheduler {
|
||||
elasticLogRef: ElasticLog<any>;
|
||||
logsScheduled = false;
|
||||
logStorage: any[] = [];
|
||||
|
||||
constructor(elasticLogRefArg: ElasticLog<any>) {
|
||||
this.elasticLogRef = elasticLogRefArg;
|
||||
}
|
||||
|
||||
addFailedLog(objectArg: any | IStandardLogParams) {
|
||||
this.logStorage.push(objectArg);
|
||||
this.setRetry();
|
||||
}
|
||||
scheduleLog(logObject: any) {
|
||||
this.logStorage.push(logObject);
|
||||
}
|
||||
|
||||
setRetry() {
|
||||
setTimeout(() => {
|
||||
const oldStorage = this.logStorage;
|
||||
this.logStorage = [];
|
||||
for (let logObject of oldStorage) {
|
||||
this.elasticLogRef.log(logObject, true);
|
||||
}
|
||||
if (this.logStorage.length === 0) {
|
||||
console.log('ElasticLog retry success!!!');
|
||||
this.logsScheduled = false;
|
||||
} else {
|
||||
console.log('ElasticLog retry failed');
|
||||
this.setRetry();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
deferSend() {
|
||||
if (!this.logsScheduled) {
|
||||
console.log('Retry ElasticLog in 5 seconds!');
|
||||
this.logsScheduled = true;
|
||||
this.setRetry();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
import * as elasticsearch from 'elasticsearch';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
||||
export { elasticsearch, smartdelay, smartlogInterfaces };
|
88
ts/elasticsearch.classes.elasticindex.ts
Normal file
88
ts/elasticsearch.classes.elasticindex.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import * as plugins from './elasticsearch.plugins';
|
||||
import { ElasticSearch } from './elasticsearch.classes.elasticsearch';
|
||||
import { ILogPackage } from '@pushrocks/smartlog-interfaces';
|
||||
|
||||
import { Stringmap } from '@pushrocks/lik';
|
||||
|
||||
export class ElasticIndex {
|
||||
private stringmap = new Stringmap();
|
||||
private elasticSearchRef: ElasticSearch<any>;
|
||||
|
||||
constructor(elasticSearchInstanceArg: ElasticSearch<ILogPackage>) {
|
||||
this.elasticSearchRef = elasticSearchInstanceArg;
|
||||
}
|
||||
|
||||
public async ensureIndex(indexArg: string) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
if (this.stringmap.checkString(indexArg)) {
|
||||
done.resolve();
|
||||
return;
|
||||
}
|
||||
this.elasticSearchRef.client.cat.indices(
|
||||
{
|
||||
format: 'json',
|
||||
bytes: 'm'
|
||||
},
|
||||
async (err, response: any[]) => {
|
||||
// lets delete indexes that violate the retention
|
||||
const filteredIndices = response.filter(indexObjectArg => {
|
||||
return indexObjectArg.index.startsWith('smartlog');
|
||||
});
|
||||
const filteredIndexNames = filteredIndices.map(indexObjectArg => {
|
||||
return indexObjectArg.index;
|
||||
});
|
||||
const todayAsUnix: number = Date.now();
|
||||
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
|
||||
this.elasticSearchRef.indexRetention
|
||||
);
|
||||
console.log(filteredIndexNames);
|
||||
for (const indexName of filteredIndexNames) {
|
||||
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName);
|
||||
const dateAsUnix: number = new Date(
|
||||
`${regexResult[1]}-${regexResult[2]}-${regexResult[3]}`
|
||||
).getTime();
|
||||
if (todayAsUnix - rententionPeriodAsUnix > dateAsUnix) {
|
||||
console.log(`found old index ${indexName}`);
|
||||
const done2 = plugins.smartpromise.defer();
|
||||
this.elasticSearchRef.client.indices.delete(
|
||||
{
|
||||
index: indexName
|
||||
},
|
||||
(err2, response2) => {
|
||||
if (err2) {
|
||||
console.log(err2);
|
||||
}
|
||||
console.log(`deleted ${indexName}`);
|
||||
done2.resolve();
|
||||
}
|
||||
);
|
||||
await done2.promise;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(response);
|
||||
const index = response.find(indexObject => {
|
||||
return indexObject.index === indexArg;
|
||||
});
|
||||
|
||||
if (!index) {
|
||||
const done2 = plugins.smartpromise.defer();
|
||||
this.elasticSearchRef.client.indices.create(
|
||||
{
|
||||
waitForActiveShards: '2',
|
||||
index: indexArg
|
||||
},
|
||||
(error, response) => {
|
||||
// console.lof(response)
|
||||
done2.resolve();
|
||||
}
|
||||
);
|
||||
await done2.promise;
|
||||
}
|
||||
this.stringmap.addString(indexArg);
|
||||
done.resolve();
|
||||
}
|
||||
);
|
||||
await done.promise;
|
||||
}
|
||||
}
|
44
ts/elasticsearch.classes.elasticscheduler.ts
Normal file
44
ts/elasticsearch.classes.elasticscheduler.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { ElasticSearch, IStandardLogParams } from './elasticsearch.classes.elasticsearch';
|
||||
|
||||
export class ElasticScheduler {
|
||||
elasticSearchRef: ElasticSearch<any>;
|
||||
docsScheduled = false;
|
||||
docsStorage: any[] = [];
|
||||
|
||||
constructor(elasticLogRefArg: ElasticSearch<any>) {
|
||||
this.elasticSearchRef = elasticLogRefArg;
|
||||
}
|
||||
|
||||
public addFailedDoc(objectArg: any | IStandardLogParams) {
|
||||
this.docsStorage.push(objectArg);
|
||||
this.setRetry();
|
||||
}
|
||||
public scheduleDoc(logObject: any) {
|
||||
this.docsStorage.push(logObject);
|
||||
}
|
||||
|
||||
public setRetry() {
|
||||
setTimeout(() => {
|
||||
const oldStorage = this.docsStorage;
|
||||
this.docsStorage = [];
|
||||
for (let logObject of oldStorage) {
|
||||
this.elasticSearchRef.log(logObject, true);
|
||||
}
|
||||
if (this.docsStorage.length === 0) {
|
||||
console.log('ElasticLog retry success!!!');
|
||||
this.docsScheduled = false;
|
||||
} else {
|
||||
console.log('ElasticLog retry failed');
|
||||
this.setRetry();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
public deferSend() {
|
||||
if (!this.docsScheduled) {
|
||||
console.log('Retry ElasticLog in 5 seconds!');
|
||||
this.docsScheduled = true;
|
||||
this.setRetry();
|
||||
}
|
||||
}
|
||||
}
|
104
ts/elasticsearch.classes.elasticsearch.ts
Normal file
104
ts/elasticsearch.classes.elasticsearch.ts
Normal file
@ -0,0 +1,104 @@
|
||||
// interfaces
|
||||
import { Client as ElasticClient } from 'elasticsearch';
|
||||
import { ILogContext, ILogPackage, ILogDestination } from '@pushrocks/smartlog-interfaces';
|
||||
|
||||
// other classes
|
||||
import { ElasticScheduler } from './elasticsearch.classes.elasticscheduler';
|
||||
import { ElasticIndex } from './elasticsearch.classes.elasticindex';
|
||||
|
||||
export interface IStandardLogParams {
|
||||
message: string;
|
||||
severity: string;
|
||||
}
|
||||
|
||||
export interface IElasticSearchConstructorOptions {
|
||||
indexPrefix: string;
|
||||
indexRetention: number;
|
||||
port: number;
|
||||
domain: string;
|
||||
ssl: boolean;
|
||||
user?: string;
|
||||
pass?: string;
|
||||
}
|
||||
|
||||
export class ElasticSearch<T> {
|
||||
public client: ElasticClient;
|
||||
public elasticScheduler = new ElasticScheduler(this);
|
||||
public elasticIndex: ElasticIndex = new ElasticIndex(this);
|
||||
|
||||
public indexPrefix: string;
|
||||
public indexRetention: number;
|
||||
|
||||
/**
|
||||
* sets up an instance of Elastic log
|
||||
* @param optionsArg
|
||||
*/
|
||||
constructor(optionsArg: IElasticSearchConstructorOptions) {
|
||||
this.client = new ElasticClient({
|
||||
host: this.computeHostString(optionsArg)
|
||||
// log: 'trace'
|
||||
});
|
||||
this.indexPrefix = optionsArg.indexPrefix;
|
||||
this.indexRetention = optionsArg.indexRetention;
|
||||
}
|
||||
|
||||
/**
|
||||
* computes the host string from the constructor options
|
||||
* @param optionsArg
|
||||
*/
|
||||
private computeHostString(optionsArg: IElasticSearchConstructorOptions): string {
|
||||
let hostString = `${optionsArg.domain}:${optionsArg.port}`;
|
||||
if (optionsArg.user && optionsArg.pass) {
|
||||
hostString = `${optionsArg.user}:${optionsArg.pass}@${hostString}`;
|
||||
}
|
||||
if (optionsArg.ssl) {
|
||||
hostString = `https://${hostString}`;
|
||||
} else {
|
||||
hostString = `http://${hostString}`;
|
||||
}
|
||||
return hostString;
|
||||
}
|
||||
|
||||
public async log(logPackageArg: ILogPackage, scheduleOverwrite = false) {
|
||||
const now = new Date();
|
||||
const indexToUse = `${this.indexPrefix}-${now.getFullYear()}.${(
|
||||
'0' +
|
||||
(now.getMonth() + 1)
|
||||
).slice(-2)}.${('0' + now.getDate()).slice(-2)}`;
|
||||
|
||||
if (this.elasticScheduler.docsScheduled && !scheduleOverwrite) {
|
||||
this.elasticScheduler.scheduleDoc(logPackageArg);
|
||||
return;
|
||||
}
|
||||
|
||||
await this.elasticIndex.ensureIndex(indexToUse);
|
||||
|
||||
this.client.index(
|
||||
{
|
||||
index: indexToUse,
|
||||
type: 'log',
|
||||
body: {
|
||||
'@timestamp': new Date(logPackageArg.timestamp).toISOString(),
|
||||
...logPackageArg
|
||||
}
|
||||
},
|
||||
(error, response) => {
|
||||
if (error) {
|
||||
console.log('ElasticLog encountered an error:');
|
||||
console.log(error);
|
||||
this.elasticScheduler.addFailedDoc(logPackageArg);
|
||||
} else {
|
||||
// console.log(`ElasticLog: ${logPackageArg.message}`);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
get logDestination(): ILogDestination {
|
||||
return {
|
||||
handleLog: (smartlogPackageArg: ILogPackage) => {
|
||||
this.log(smartlogPackageArg);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
8
ts/elasticsearch.plugins.ts
Normal file
8
ts/elasticsearch.plugins.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import * as elasticsearch from 'elasticsearch';
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smarttime from '@pushrocks/smarttime';
|
||||
|
||||
export { elasticsearch, lik, smartdelay, smartlogInterfaces, smartpromise, smarttime };
|
@ -1 +1 @@
|
||||
export * from './elasticlog.classes.elasticlog';
|
||||
export * from './elasticsearch.classes.elasticsearch';
|
||||
|
Reference in New Issue
Block a user