@nsshunt/stsappframework 3.0.64 → 3.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/influxdb/influxDBManager.js +117 -107
- package/dist/influxdb/influxDBManager.js.map +1 -1
- package/dist/influxdb/influxDBManagerAgent.js +40 -34
- package/dist/influxdb/influxDBManagerAgent.js.map +1 -1
- package/dist/influxdb/influxDBManagerBase.js +2 -7
- package/dist/influxdb/influxDBManagerBase.js.map +1 -1
- package/dist/influxdb/influxDBManagerService.js +50 -44
- package/dist/influxdb/influxDBManagerService.js.map +1 -1
- package/package.json +1 -1
- package/src/influxdb/influxDBManager.ts +127 -116
- package/src/influxdb/influxDBManagerAgent.ts +41 -36
- package/src/influxdb/influxDBManagerBase.ts +2 -8
- package/src/influxdb/influxDBManagerService.ts +54 -49
- package/types/influxdb/influxDBManager.d.ts +2 -0
- package/types/influxdb/influxDBManager.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerAgent.d.ts +2 -2
- package/types/influxdb/influxDBManagerAgent.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerBase.d.ts +2 -3
- package/types/influxdb/influxDBManagerBase.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerService.d.ts +2 -2
- package/types/influxdb/influxDBManagerService.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerService.js","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerService.ts"],"names":[],"mappings":";AAAA,wFAAwF,CAAE,UAAU;AACpG,4FAA4F;AAC5F,+GAA+G;;;AAE/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwGE;AAEF,iEAAuE;AAEvE,oEAAuE;AAEvE,+DAA2D;AAK3D,MAAM,UAAU,GAAG,yBAAyB,CAAA;AAE5C;;;;;E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U,EAAE,iBAAiB,CAAC,WAAW,CAAC,0BAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC;qBAC/E,UAAU,CAAC,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,0BAAK,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC;qBAC7E,UAAU,CAAC,WAAW,EAAE,SAAS,CAAC;qBAClC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,WAAW,CAAC,0BAAK,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;gBAEjG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBAC3B,OAAO,IAAI,CAAC;aACf;YAAC,OAAO,KAAU,EAAE;gBACjB,OAAO,CAAC,KAAK,CAAC,GAAG,UAAU,gDAAgD,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;gBACzF,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;gBAClE,OAAO,KAAK,CAAC;aAChB;SACJ;aAAM;YACH,OAAO,CAAC,KAAK,CAAC,GAAG,UAAU,0EAA0E,CAAC,GAAG,CAAC,CAAC;YAC3G,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;CACJ;AA3OD,wDA2OC"}
|
package/package.json
CHANGED
|
@@ -207,7 +207,7 @@ export class InfluxDBManager
|
|
|
207
207
|
#org = '' // `my-org`
|
|
208
208
|
#bucket = '' // `TestBucket01`
|
|
209
209
|
#client: InfluxDB;
|
|
210
|
-
#writeClient: WriteApi;
|
|
210
|
+
#writeClient: WriteApi | null = null;
|
|
211
211
|
#queryApi: QueryApi;
|
|
212
212
|
#writeDataPointFlushTimeout: NodeJS.Timeout | null = null;
|
|
213
213
|
#agent: Agent | null = null;
|
|
@@ -263,106 +263,9 @@ export class InfluxDBManager
|
|
|
263
263
|
this.#BoostrapInfluxDB();
|
|
264
264
|
|
|
265
265
|
this.#queryApi = this.#client.getQueryApi(this.#org);
|
|
266
|
-
|
|
267
|
-
/* Defaults from the library as at 12/11/2023
|
|
268
|
-
// default RetryDelayStrategyOptions
|
|
269
|
-
export const DEFAULT_RetryDelayStrategyOptions = {
|
|
270
|
-
retryJitter: 200,
|
|
271
|
-
minRetryDelay: 5000,
|
|
272
|
-
maxRetryDelay: 125000,
|
|
273
|
-
exponentialBase: 5,
|
|
274
|
-
randomRetry: true,
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// default writeOptions
|
|
278
|
-
export const DEFAULT_WriteOptions: WriteOptions = {
|
|
279
|
-
batchSize: 1000,
|
|
280
|
-
maxBatchBytes: 50_000_000, // default max batch size in the cloud
|
|
281
|
-
flushInterval: 60000,
|
|
282
|
-
writeFailed: function () {},
|
|
283
|
-
writeSuccess: function () {},
|
|
284
|
-
writeRetrySkipped: function () {},
|
|
285
|
-
maxRetries: 5,
|
|
286
|
-
maxRetryTime: 180_000,
|
|
287
|
-
maxBufferLines: 32_000,
|
|
288
|
-
// a copy of DEFAULT_RetryDelayStrategyOptions, so that DEFAULT_WriteOptions could be tree-shaken
|
|
289
|
-
retryJitter: 200,
|
|
290
|
-
minRetryDelay: 5000,
|
|
291
|
-
maxRetryDelay: 125000,
|
|
292
|
-
exponentialBase: 2,
|
|
293
|
-
gzipThreshold: 1000,
|
|
294
|
-
randomRetry: true,
|
|
295
|
-
}
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
const flushBatchSize = DEFAULT_WriteOptions.batchSize;
|
|
299
|
-
|
|
300
|
-
const writeOptions: Partial<WriteOptions> = {
|
|
301
|
-
/* the maximum points/lines to send in a single batch to InfluxDB server */
|
|
302
|
-
batchSize: flushBatchSize + 1, // don't let automatically flush data
|
|
303
|
-
/* default tags to add to every point */
|
|
304
|
-
//defaultTags: {location: hostname},
|
|
305
|
-
/* maximum time in millis to keep points in an unflushed batch, 0 means don't periodically flush */
|
|
306
|
-
flushInterval: 0,
|
|
307
|
-
// max size of a batch in bytes
|
|
308
|
-
maxBatchBytes: 50_000_000, // default max batch size in the cloud
|
|
309
|
-
|
|
310
|
-
// Retry Options
|
|
311
|
-
|
|
312
|
-
/* maximum size of the retry buffer - it contains items that could not be sent for the first time */
|
|
313
|
-
maxBufferLines: 30000,
|
|
314
|
-
/* the count of internally-scheduled retries upon write failure, the delays between write attempts follow an exponential backoff strategy if there is no Retry-After HTTP header */
|
|
315
|
-
maxRetries: 5, // do not retry writes
|
|
316
|
-
// max time (millis) that can be spent with retries
|
|
317
|
-
maxRetryTime: 180_000,
|
|
318
|
-
|
|
319
|
-
// ... there are more write options that can be customized, see
|
|
320
|
-
// https://influxdata.github.io/influxdb-client-js/influxdb-client.writeoptions.html and
|
|
321
|
-
// https://influxdata.github.io/influxdb-client-js/influxdb-client.writeretryoptions.html
|
|
322
|
-
writeFailed(error, lines, attempt, expires) {
|
|
323
|
-
debug(`writeOptions:writeSuccess(): Error: [${error}], Attempt: [${attempt}], Expires: [${expires}], Lines: [${lines}]`.red);
|
|
324
|
-
},
|
|
325
|
-
writeSuccess(lines) {
|
|
326
|
-
debug(`writeOptions:writeSuccess(): Lines: [${lines}]`.green);
|
|
327
|
-
},
|
|
328
|
-
writeRetrySkipped(entry) {
|
|
329
|
-
debug(`writeOptions:writeSuccess(): Expires: [${entry.expires}], Lines: [${entry.lines}]`.magenta);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
this.#writeClient = this.#client.getWriteApi(this.#org, this.#bucket, 'ns', writeOptions);
|
|
334
266
|
|
|
335
267
|
this.CreateInfluxDBManagerClient('service');
|
|
336
268
|
this.CreateInfluxDBManagerClient('agent');
|
|
337
|
-
|
|
338
|
-
let attemptCount = 0;
|
|
339
|
-
const maxAttemptCount = 5;
|
|
340
|
-
const normalFlushDelay = 1000;
|
|
341
|
-
const retryFlushDelay = 2500;
|
|
342
|
-
|
|
343
|
-
const StartWriteClient = (delay: number) => {
|
|
344
|
-
this.#writeDataPointFlushTimeout = setTimeout(async () => {
|
|
345
|
-
try {
|
|
346
|
-
attemptCount++;
|
|
347
|
-
const start = performance.now();
|
|
348
|
-
await this.#writeClient.flush();
|
|
349
|
-
const end = performance.now();
|
|
350
|
-
debug(`InfluxDB Flush time: [${end-start}]`.grey)
|
|
351
|
-
attemptCount = 0;
|
|
352
|
-
StartWriteClient(normalFlushDelay);
|
|
353
|
-
} catch (error) {
|
|
354
|
-
console.error(`InfluxDBManager:StartWriteClient(): Attempt: [${attemptCount}], Error: [${error}]`.red)
|
|
355
|
-
if (attemptCount === maxAttemptCount) {
|
|
356
|
-
console.error(`InfluxDBManager:StartWriteClient(): Max Attempts reached. Will no longer retry.`.red);
|
|
357
|
-
console.error(`InfluxDBManager:StartWriteClient(): InfluxDB data capture ended in permanent faiilure.`.red);
|
|
358
|
-
} else {
|
|
359
|
-
StartWriteClient(retryFlushDelay);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}, delay).unref();
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
StartWriteClient(normalFlushDelay);
|
|
366
269
|
}
|
|
367
270
|
|
|
368
271
|
#BoostrapInfluxDB = async(): Promise<void> => {
|
|
@@ -386,10 +289,10 @@ export class InfluxDBManager
|
|
|
386
289
|
CreateInfluxDBManagerClient(modelType: string) {
|
|
387
290
|
switch (modelType) {
|
|
388
291
|
case 'service':
|
|
389
|
-
this.#influxDBManagerClients[modelType] = new InfluxDBManagerService(this.#options, this.#queryApi
|
|
292
|
+
this.#influxDBManagerClients[modelType] = new InfluxDBManagerService(this.#options, this.#queryApi);
|
|
390
293
|
break;
|
|
391
294
|
case 'agent':
|
|
392
|
-
this.#influxDBManagerClients[modelType] = new InfluxDBManagerAgent(this.#options, this.#queryApi
|
|
295
|
+
this.#influxDBManagerClients[modelType] = new InfluxDBManagerAgent(this.#options, this.#queryApi);
|
|
393
296
|
break;
|
|
394
297
|
default:
|
|
395
298
|
throw new Error(`Model type: [${modelType} not supported.]`);
|
|
@@ -413,22 +316,26 @@ export class InfluxDBManager
|
|
|
413
316
|
console.log(`${_logPrefix}Terminate: Terminate already called. Ignoring.`.yellow);
|
|
414
317
|
} else {
|
|
415
318
|
this.#shuttingDown = true;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
319
|
+
if (this.#writeClient) {
|
|
320
|
+
try {
|
|
321
|
+
this.#writeClient.flush();
|
|
322
|
+
this.#shuttingDown = true;
|
|
323
|
+
if (this.#writeDataPointFlushTimeout) {
|
|
324
|
+
clearTimeout(this.#writeDataPointFlushTimeout);
|
|
325
|
+
this.#writeDataPointFlushTimeout = null;
|
|
326
|
+
}
|
|
423
327
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
328
|
+
if (this.#agent) {
|
|
329
|
+
this.#agent?.destroy();
|
|
330
|
+
this.#agent = null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
this.#writeClient = null;
|
|
428
334
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
335
|
+
console.log(`ProducerDisconnect`.yellow);
|
|
336
|
+
} catch (error) {
|
|
337
|
+
console.error(`${_logPrefix}#Terminate: Error: [${error}]`.red);
|
|
338
|
+
}
|
|
432
339
|
}
|
|
433
340
|
}
|
|
434
341
|
}
|
|
@@ -463,6 +370,110 @@ export class InfluxDBManager
|
|
|
463
370
|
return combinedResults;
|
|
464
371
|
}
|
|
465
372
|
|
|
373
|
+
get writeClient(): WriteApi {
|
|
374
|
+
if (!this.#writeClient) {
|
|
375
|
+
/* Defaults from the library as at 12/11/2023
|
|
376
|
+
// default RetryDelayStrategyOptions
|
|
377
|
+
export const DEFAULT_RetryDelayStrategyOptions = {
|
|
378
|
+
retryJitter: 200,
|
|
379
|
+
minRetryDelay: 5000,
|
|
380
|
+
maxRetryDelay: 125000,
|
|
381
|
+
exponentialBase: 5,
|
|
382
|
+
randomRetry: true,
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// default writeOptions
|
|
386
|
+
export const DEFAULT_WriteOptions: WriteOptions = {
|
|
387
|
+
batchSize: 1000,
|
|
388
|
+
maxBatchBytes: 50_000_000, // default max batch size in the cloud
|
|
389
|
+
flushInterval: 60000,
|
|
390
|
+
writeFailed: function () {},
|
|
391
|
+
writeSuccess: function () {},
|
|
392
|
+
writeRetrySkipped: function () {},
|
|
393
|
+
maxRetries: 5,
|
|
394
|
+
maxRetryTime: 180_000,
|
|
395
|
+
maxBufferLines: 32_000,
|
|
396
|
+
// a copy of DEFAULT_RetryDelayStrategyOptions, so that DEFAULT_WriteOptions could be tree-shaken
|
|
397
|
+
retryJitter: 200,
|
|
398
|
+
minRetryDelay: 5000,
|
|
399
|
+
maxRetryDelay: 125000,
|
|
400
|
+
exponentialBase: 2,
|
|
401
|
+
gzipThreshold: 1000,
|
|
402
|
+
randomRetry: true,
|
|
403
|
+
}
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
const flushBatchSize = DEFAULT_WriteOptions.batchSize;
|
|
407
|
+
|
|
408
|
+
const writeOptions: Partial<WriteOptions> = {
|
|
409
|
+
/* the maximum points/lines to send in a single batch to InfluxDB server */
|
|
410
|
+
batchSize: flushBatchSize + 1, // don't let automatically flush data
|
|
411
|
+
/* default tags to add to every point */
|
|
412
|
+
//defaultTags: {location: hostname},
|
|
413
|
+
/* maximum time in millis to keep points in an unflushed batch, 0 means don't periodically flush */
|
|
414
|
+
flushInterval: 0,
|
|
415
|
+
// max size of a batch in bytes
|
|
416
|
+
maxBatchBytes: 50_000_000, // default max batch size in the cloud
|
|
417
|
+
|
|
418
|
+
// Retry Options
|
|
419
|
+
|
|
420
|
+
/* maximum size of the retry buffer - it contains items that could not be sent for the first time */
|
|
421
|
+
maxBufferLines: 30000,
|
|
422
|
+
/* the count of internally-scheduled retries upon write failure, the delays between write attempts follow an exponential backoff strategy if there is no Retry-After HTTP header */
|
|
423
|
+
maxRetries: 5, // do not retry writes
|
|
424
|
+
// max time (millis) that can be spent with retries
|
|
425
|
+
maxRetryTime: 180_000,
|
|
426
|
+
|
|
427
|
+
// ... there are more write options that can be customized, see
|
|
428
|
+
// https://influxdata.github.io/influxdb-client-js/influxdb-client.writeoptions.html and
|
|
429
|
+
// https://influxdata.github.io/influxdb-client-js/influxdb-client.writeretryoptions.html
|
|
430
|
+
writeFailed(error, lines, attempt, expires) {
|
|
431
|
+
debug(`writeOptions:writeSuccess(): Error: [${error}], Attempt: [${attempt}], Expires: [${expires}], Lines: [${lines}]`.red);
|
|
432
|
+
},
|
|
433
|
+
writeSuccess(lines) {
|
|
434
|
+
debug(`writeOptions:writeSuccess(): Lines: [${lines}]`.green);
|
|
435
|
+
},
|
|
436
|
+
writeRetrySkipped(entry) {
|
|
437
|
+
debug(`writeOptions:writeSuccess(): Expires: [${entry.expires}], Lines: [${entry.lines}]`.magenta);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this.#writeClient = this.#client.getWriteApi(this.#org, this.#bucket, 'ns', writeOptions);
|
|
442
|
+
|
|
443
|
+
let attemptCount = 0;
|
|
444
|
+
const maxAttemptCount = 5;
|
|
445
|
+
const normalFlushDelay = 1000;
|
|
446
|
+
const retryFlushDelay = 2500;
|
|
447
|
+
|
|
448
|
+
const StartWriteClient = (delay: number) => {
|
|
449
|
+
this.#writeDataPointFlushTimeout = setTimeout(async () => {
|
|
450
|
+
if (this.#writeClient) {
|
|
451
|
+
try {
|
|
452
|
+
attemptCount++;
|
|
453
|
+
const start = performance.now();
|
|
454
|
+
await this.#writeClient.flush();
|
|
455
|
+
const end = performance.now();
|
|
456
|
+
debug(`InfluxDB Flush time: [${end-start}]`.grey)
|
|
457
|
+
attemptCount = 0;
|
|
458
|
+
StartWriteClient(normalFlushDelay);
|
|
459
|
+
} catch (error) {
|
|
460
|
+
console.error(`InfluxDBManager:StartWriteClient(): Attempt: [${attemptCount}], Error: [${error}]`.red)
|
|
461
|
+
if (attemptCount === maxAttemptCount) {
|
|
462
|
+
console.error(`InfluxDBManager:StartWriteClient(): Max Attempts reached. Will no longer retry.`.red);
|
|
463
|
+
console.error(`InfluxDBManager:StartWriteClient(): InfluxDB data capture ended in permanent faiilure.`.red);
|
|
464
|
+
} else {
|
|
465
|
+
StartWriteClient(retryFlushDelay);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}, delay).unref();
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
StartWriteClient(normalFlushDelay);
|
|
473
|
+
}
|
|
474
|
+
return this.#writeClient;
|
|
475
|
+
}
|
|
476
|
+
|
|
466
477
|
// Agent context payload
|
|
467
478
|
// {"nid":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","id":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","hostName":"somehost","agentName":"e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent","threadId":"MainProcess","asyncRunnerId":"0"}
|
|
468
479
|
async OutputInfluxDB(instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
@@ -471,9 +482,9 @@ export class InfluxDBManager
|
|
|
471
482
|
return false;
|
|
472
483
|
}
|
|
473
484
|
if (instrumentPayload.context.agentName) {
|
|
474
|
-
return this.#influxDBManagerClients['agent'].OutputInfluxDB(instrumentPayload);
|
|
485
|
+
return this.#influxDBManagerClients['agent'].OutputInfluxDB(this.writeClient, instrumentPayload);
|
|
475
486
|
} else {
|
|
476
|
-
return this.#influxDBManagerClients['service'].OutputInfluxDB(instrumentPayload);
|
|
487
|
+
return this.#influxDBManagerClients['service'].OutputInfluxDB(this.writeClient, instrumentPayload);
|
|
477
488
|
}
|
|
478
489
|
} catch (error) {
|
|
479
490
|
console.error(`${_logPrefix}OutputInfluxDB: Could not write data point: [${error}]`.red);
|
|
@@ -112,8 +112,8 @@ const _logPrefix = 'InfluxDBManagerService:'
|
|
|
112
112
|
|
|
113
113
|
export class InfluxDBManagerAgent extends InfluxDBManagerBase
|
|
114
114
|
{
|
|
115
|
-
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi
|
|
116
|
-
super(options, queryApi
|
|
115
|
+
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi) {
|
|
116
|
+
super(options, queryApi);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
override get modelType(): string {
|
|
@@ -264,41 +264,46 @@ export class InfluxDBManagerAgent extends InfluxDBManagerBase
|
|
|
264
264
|
// Agent context payload
|
|
265
265
|
// {"nid":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","id":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","hostName":"somehost"
|
|
266
266
|
// ,"agentName":"e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent","threadId":"MainProcess","asyncRunnerId":"0"}
|
|
267
|
-
async OutputInfluxDB(instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
async OutputInfluxDB(writeApi: WriteApi, instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
268
|
+
if (writeApi) {
|
|
269
|
+
try {
|
|
270
|
+
const { nid, id, hostName, agentName, threadId, asyncRunnerId } = instrumentPayload.context;
|
|
271
|
+
|
|
272
|
+
let systemcpu = 0.0;
|
|
273
|
+
if (instrumentPayload.instruments[Gauge.CPU_SYSTEM_LOAD_GAUGE]) {
|
|
274
|
+
systemcpu = (instrumentPayload.instruments[Gauge.CPU_SYSTEM_LOAD_GAUGE].val as number);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const point = new Point('all')
|
|
278
|
+
.measurement('agent')
|
|
279
|
+
// Context settings
|
|
280
|
+
.tag('id', id as string) // Must be unique (uuid)
|
|
281
|
+
.tag('hostName', hostName as string) // Must be unique (uuid)
|
|
282
|
+
.tag('agentName', agentName as string) // Must be unique (uuid)
|
|
283
|
+
.tag('threadId', threadId as string) // Must be unique (uuid)
|
|
284
|
+
.tag('asyncRunnerId', asyncRunnerId as string)
|
|
285
|
+
// Data fields
|
|
286
|
+
.intField('requestCount', instrumentPayload.instruments[Gauge.REQUEST_COUNT_GAUGE].val) // q
|
|
287
|
+
.intField('errorCount', instrumentPayload.instruments[Gauge.ERROR_COUNT_GAUGE].val) // j
|
|
288
|
+
.intField('retryCount', instrumentPayload.instruments[Gauge.RETRY_COUNT_GAUGE].val) // r
|
|
289
|
+
.intField('authenticationCount', instrumentPayload.instruments[Gauge.AUTHENTICATION_COUNT_GAUGE].val) // b
|
|
290
|
+
.floatField('velocity', (instrumentPayload.instruments[Gauge.VELOCITY_GAUGE] as InstrumentVelocity).va) // t - Note: Using va not val here
|
|
291
|
+
.intField('coreCount', instrumentPayload.instruments[Gauge.CORE_COUNT_GAUGE].val) // x
|
|
292
|
+
.floatField('timer', instrumentPayload.instruments[Gauge.TIMER_GAUGE].val) // s
|
|
293
|
+
.floatField('duration', instrumentPayload.instruments[Gauge.DURATION_GAUGE].val) // h
|
|
294
|
+
.floatField('latency', instrumentPayload.instruments[Gauge.LATENCY_GAUGE].val) // h
|
|
295
|
+
.intField('activeRequestCount', instrumentPayload.instruments[Gauge.ACTIVE_REQUEST_GAUGE].val) // a
|
|
296
|
+
.intField('childCount', instrumentPayload.instruments[Gauge.CHILD_COUNT].val) // y
|
|
297
|
+
// logger // m
|
|
298
|
+
// duration histo // i
|
|
299
|
+
writeApi.writePoint(point);
|
|
300
|
+
return true;
|
|
301
|
+
} catch (error: any) {
|
|
302
|
+
console.error(`${_logPrefix}OutputInfluxDBAgent: Could not write data point: [${error}]`.red);
|
|
303
|
+
return false;
|
|
274
304
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
.measurement('agent')
|
|
278
|
-
// Context settings
|
|
279
|
-
.tag('id', id as string) // Must be unique (uuid)
|
|
280
|
-
.tag('hostName', hostName as string) // Must be unique (uuid)
|
|
281
|
-
.tag('agentName', agentName as string) // Must be unique (uuid)
|
|
282
|
-
.tag('threadId', threadId as string) // Must be unique (uuid)
|
|
283
|
-
.tag('asyncRunnerId', asyncRunnerId as string)
|
|
284
|
-
// Data fields
|
|
285
|
-
.intField('requestCount', instrumentPayload.instruments[Gauge.REQUEST_COUNT_GAUGE].val) // q
|
|
286
|
-
.intField('errorCount', instrumentPayload.instruments[Gauge.ERROR_COUNT_GAUGE].val) // j
|
|
287
|
-
.intField('retryCount', instrumentPayload.instruments[Gauge.RETRY_COUNT_GAUGE].val) // r
|
|
288
|
-
.intField('authenticationCount', instrumentPayload.instruments[Gauge.AUTHENTICATION_COUNT_GAUGE].val) // b
|
|
289
|
-
.floatField('velocity', (instrumentPayload.instruments[Gauge.VELOCITY_GAUGE] as InstrumentVelocity).va) // t - Note: Using va not val here
|
|
290
|
-
.intField('coreCount', instrumentPayload.instruments[Gauge.CORE_COUNT_GAUGE].val) // x
|
|
291
|
-
.floatField('timer', instrumentPayload.instruments[Gauge.TIMER_GAUGE].val) // s
|
|
292
|
-
.floatField('duration', instrumentPayload.instruments[Gauge.DURATION_GAUGE].val) // h
|
|
293
|
-
.floatField('latency', instrumentPayload.instruments[Gauge.LATENCY_GAUGE].val) // h
|
|
294
|
-
.intField('activeRequestCount', instrumentPayload.instruments[Gauge.ACTIVE_REQUEST_GAUGE].val) // a
|
|
295
|
-
.intField('childCount', instrumentPayload.instruments[Gauge.CHILD_COUNT].val) // y
|
|
296
|
-
// logger // m
|
|
297
|
-
// duration histo // i
|
|
298
|
-
this.writeClient.writePoint(point);
|
|
299
|
-
return true;
|
|
300
|
-
} catch (error: any) {
|
|
301
|
-
console.error(`${_logPrefix}OutputInfluxDBAgent: Could not write data point: [${error}]`.red);
|
|
305
|
+
} else {
|
|
306
|
+
console.error(`${_logPrefix}OutputInfluxDBAgent: Could not write data point as writeClient is null`.red);
|
|
302
307
|
return false;
|
|
303
308
|
}
|
|
304
309
|
}
|
|
@@ -12,13 +12,11 @@ const _logPrefix = 'InfluxDBManager:'
|
|
|
12
12
|
export class InfluxDBManagerBase
|
|
13
13
|
{
|
|
14
14
|
#queryApi: QueryApi;
|
|
15
|
-
#writeClient: WriteApi;
|
|
16
15
|
#shuttingDown: boolean = false;
|
|
17
16
|
#options: IInfluxDBManagerOptions;
|
|
18
17
|
|
|
19
|
-
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi
|
|
18
|
+
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi) {
|
|
20
19
|
this.#queryApi = queryApi;
|
|
21
|
-
this.#writeClient = writeClient;
|
|
22
20
|
this.#options = options;
|
|
23
21
|
}
|
|
24
22
|
|
|
@@ -29,10 +27,6 @@ export class InfluxDBManagerBase
|
|
|
29
27
|
return this.#queryApi;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
get writeClient() {
|
|
33
|
-
return this.#writeClient;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
30
|
get shuttingDown() {
|
|
37
31
|
return this.#shuttingDown;
|
|
38
32
|
}
|
|
@@ -109,7 +103,7 @@ export class InfluxDBManagerBase
|
|
|
109
103
|
|
|
110
104
|
// Agent context payload
|
|
111
105
|
// {"nid":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","id":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","hostName":"somehost","agentName":"e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent","threadId":"MainProcess","asyncRunnerId":"0"}
|
|
112
|
-
async OutputInfluxDB(instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
106
|
+
async OutputInfluxDB(writeApi: WriteApi, instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
113
107
|
throw new Error('Must override in sub-class');
|
|
114
108
|
}
|
|
115
109
|
}
|
|
@@ -133,8 +133,8 @@ const SERVICE_STATS_GLOBAL = "sts-stats-globalservice";
|
|
|
133
133
|
|
|
134
134
|
export class InfluxDBManagerService extends InfluxDBManagerBase
|
|
135
135
|
{
|
|
136
|
-
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi
|
|
137
|
-
super(options, queryApi
|
|
136
|
+
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi) {
|
|
137
|
+
super(options, queryApi);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
override get modelType(): string {
|
|
@@ -309,55 +309,60 @@ data
|
|
|
309
309
|
// Write data points ----------------------------------------------------------------------------------------------
|
|
310
310
|
// Agent context payload
|
|
311
311
|
// {"nid":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","id":"somehost@e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent|MainProcess|0","hostName":"somehost","agentName":"e58f5d75-6ff6-4e04-92a4-f2bcd722fec0-someuseragent","threadId":"MainProcess","asyncRunnerId":"0"}
|
|
312
|
-
async OutputInfluxDB(instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
async OutputInfluxDB(writeApi: WriteApi, instrumentPayload: InstrumentPayload): Promise<boolean> {
|
|
313
|
+
if (writeApi) {
|
|
314
|
+
try {
|
|
315
|
+
if (this.shuttingDown) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const { serviceId, serviceInstanceId, hostName, serviceInstanceProcessId,
|
|
320
|
+
pid, ppid, serviceName, serviceVersion } = instrumentPayload.context;
|
|
321
|
+
|
|
322
|
+
let systemcpu = 0.0;
|
|
323
|
+
if (instrumentPayload.instruments[Gauge.CPU_SYSTEM_LOAD_GAUGE]) {
|
|
324
|
+
systemcpu = (instrumentPayload.instruments[Gauge.CPU_SYSTEM_LOAD_GAUGE].val as number);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const point = new Point('all')
|
|
328
|
+
.measurement('service')
|
|
329
|
+
// Context settings
|
|
330
|
+
.tag('serviceId', serviceId as string)
|
|
331
|
+
.tag('serviceName', serviceName as string)
|
|
332
|
+
.tag('serviceVersion', serviceVersion as string)
|
|
333
|
+
.tag('serviceInstanceId', serviceInstanceId as string)
|
|
334
|
+
.tag('serviceInstanceProcessId', serviceInstanceProcessId as string)
|
|
335
|
+
.tag('hostName', hostName as string)
|
|
336
|
+
.tag('pid', (pid as number).toString())
|
|
337
|
+
.tag('ppid', (ppid as number).toString())
|
|
338
|
+
// Data fields
|
|
339
|
+
.intField('requestCount', instrumentPayload.instruments[Gauge.REQUEST_COUNT_GAUGE].val)
|
|
340
|
+
.intField('errorCount', instrumentPayload.instruments[Gauge.ERROR_COUNT_GAUGE].val)
|
|
341
|
+
.intField('retryCount', instrumentPayload.instruments[Gauge.RETRY_COUNT_GAUGE].val)
|
|
342
|
+
.intField('authenticationCount', instrumentPayload.instruments[Gauge.AUTHENTICATION_COUNT_GAUGE].val)
|
|
343
|
+
.floatField('velocity', (instrumentPayload.instruments[Gauge.VELOCITY_GAUGE] as InstrumentVelocity).va) // Note: Using va not val here
|
|
344
|
+
.floatField('cpu', instrumentPayload.instruments[Gauge.CPU_LOAD_GAUGE].val)
|
|
345
|
+
.intField('activeRequestCount', instrumentPayload.instruments[Gauge.ACTIVE_REQUEST_GAUGE].val)
|
|
346
|
+
.intField('connectionCount', instrumentPayload.instruments[Gauge.CONNECTION_COUNT_GAUGE].val)
|
|
347
|
+
.intField('connectionPoolCount', instrumentPayload.instruments[Gauge.CONNECTION_POOL_TOTAL_GAUGE].val)
|
|
348
|
+
.intField('connectionIdleCount', instrumentPayload.instruments[Gauge.CONNECTION_POOL_IDLE_GAUGE].val)
|
|
349
|
+
.intField('connectionWaitingCount', instrumentPayload.instruments[Gauge.CONNECTION_POOL_WAITING_GAUGE].val)
|
|
350
|
+
.intField('coreCount', instrumentPayload.instruments[Gauge.CORE_COUNT_GAUGE].val)
|
|
351
|
+
.floatField('timer', instrumentPayload.instruments[Gauge.TIMER_GAUGE].val)
|
|
352
|
+
.floatField('duration', instrumentPayload.instruments[Gauge.DURATION_GAUGE].val)
|
|
353
|
+
.floatField('latency', instrumentPayload.instruments[Gauge.LATENCY_GAUGE].val)
|
|
354
|
+
.floatField('systemcpu', systemcpu)
|
|
355
|
+
.stringField('memory', JSON.stringify(instrumentPayload.instruments[Gauge.OBJECT_GAUGE].val))
|
|
356
|
+
|
|
357
|
+
writeApi.writePoint(point);
|
|
358
|
+
return true;
|
|
359
|
+
} catch (error: any) {
|
|
360
|
+
console.error(`${_logPrefix}OutputInfluxDB: Could not write data point: [${error}]`.red);
|
|
361
|
+
console.error(`${JSON.stringify(instrumentPayload.context)}`.red);
|
|
315
362
|
return false;
|
|
316
363
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
pid, ppid, serviceName, serviceVersion } = instrumentPayload.context;
|
|
320
|
-
|
|
321
|
-
let systemcpu = 0.0;
|
|
322
|
-
if (instrumentPayload.instruments[Gauge.CPU_SYSTEM_LOAD_GAUGE]) {
|
|
323
|
-
systemcpu = (instrumentPayload.instruments[Gauge.CPU_SYSTEM_LOAD_GAUGE].val as number);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
const point = new Point('all')
|
|
327
|
-
.measurement('service')
|
|
328
|
-
// Context settings
|
|
329
|
-
.tag('serviceId', serviceId as string)
|
|
330
|
-
.tag('serviceName', serviceName as string)
|
|
331
|
-
.tag('serviceVersion', serviceVersion as string)
|
|
332
|
-
.tag('serviceInstanceId', serviceInstanceId as string)
|
|
333
|
-
.tag('serviceInstanceProcessId', serviceInstanceProcessId as string)
|
|
334
|
-
.tag('hostName', hostName as string)
|
|
335
|
-
.tag('pid', (pid as number).toString())
|
|
336
|
-
.tag('ppid', (ppid as number).toString())
|
|
337
|
-
// Data fields
|
|
338
|
-
.intField('requestCount', instrumentPayload.instruments[Gauge.REQUEST_COUNT_GAUGE].val)
|
|
339
|
-
.intField('errorCount', instrumentPayload.instruments[Gauge.ERROR_COUNT_GAUGE].val)
|
|
340
|
-
.intField('retryCount', instrumentPayload.instruments[Gauge.RETRY_COUNT_GAUGE].val)
|
|
341
|
-
.intField('authenticationCount', instrumentPayload.instruments[Gauge.AUTHENTICATION_COUNT_GAUGE].val)
|
|
342
|
-
.floatField('velocity', (instrumentPayload.instruments[Gauge.VELOCITY_GAUGE] as InstrumentVelocity).va) // Note: Using va not val here
|
|
343
|
-
.floatField('cpu', instrumentPayload.instruments[Gauge.CPU_LOAD_GAUGE].val)
|
|
344
|
-
.intField('activeRequestCount', instrumentPayload.instruments[Gauge.ACTIVE_REQUEST_GAUGE].val)
|
|
345
|
-
.intField('connectionCount', instrumentPayload.instruments[Gauge.CONNECTION_COUNT_GAUGE].val)
|
|
346
|
-
.intField('connectionPoolCount', instrumentPayload.instruments[Gauge.CONNECTION_POOL_TOTAL_GAUGE].val)
|
|
347
|
-
.intField('connectionIdleCount', instrumentPayload.instruments[Gauge.CONNECTION_POOL_IDLE_GAUGE].val)
|
|
348
|
-
.intField('connectionWaitingCount', instrumentPayload.instruments[Gauge.CONNECTION_POOL_WAITING_GAUGE].val)
|
|
349
|
-
.intField('coreCount', instrumentPayload.instruments[Gauge.CORE_COUNT_GAUGE].val)
|
|
350
|
-
.floatField('timer', instrumentPayload.instruments[Gauge.TIMER_GAUGE].val)
|
|
351
|
-
.floatField('duration', instrumentPayload.instruments[Gauge.DURATION_GAUGE].val)
|
|
352
|
-
.floatField('latency', instrumentPayload.instruments[Gauge.LATENCY_GAUGE].val)
|
|
353
|
-
.floatField('systemcpu', systemcpu)
|
|
354
|
-
.stringField('memory', JSON.stringify(instrumentPayload.instruments[Gauge.OBJECT_GAUGE].val))
|
|
355
|
-
|
|
356
|
-
this.writeClient.writePoint(point);
|
|
357
|
-
return true;
|
|
358
|
-
} catch (error: any) {
|
|
359
|
-
console.error(`${_logPrefix}OutputInfluxDB: Could not write data point: [${error}]`.red);
|
|
360
|
-
console.error(`${JSON.stringify(instrumentPayload.context)}`.red);
|
|
364
|
+
} else {
|
|
365
|
+
console.error(`${_logPrefix}OutputInfluxDBService: Could not write data point as writeClient is null`.red);
|
|
361
366
|
return false;
|
|
362
367
|
}
|
|
363
368
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WriteApi } from '@influxdata/influxdb-client';
|
|
1
2
|
import { JSONObject } from '@nsshunt/stsutils';
|
|
2
3
|
import { InfluxDBManagerService } from './influxDBManagerService';
|
|
3
4
|
import { InfluxDBManagerAgent } from './influxDBManagerAgent';
|
|
@@ -12,6 +13,7 @@ export declare class InfluxDBManager {
|
|
|
12
13
|
Terminate: () => Promise<void>;
|
|
13
14
|
CreateGlobalCountModel: (stscount: any[]) => any;
|
|
14
15
|
CreateNestedObject(combinedResults: JSONObject, keyList: string[]): JSONObject;
|
|
16
|
+
get writeClient(): WriteApi;
|
|
15
17
|
OutputInfluxDB(instrumentPayload: InstrumentPayload): Promise<boolean>;
|
|
16
18
|
}
|
|
17
19
|
//# sourceMappingURL=influxDBManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManager.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"influxDBManager.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,QAAQ,EAAgD,MAAM,6BAA6B,CAAA;AAM9G,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAI9C,OAAO,EAAE,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAA2B,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AA0L7E,qBAAa,eAAe;;;IAyFxB,2BAA2B,CAAC,SAAS,EAAE,MAAM;IAa7C,IAAI,cAAc,IAAI,sBAAsB,CAE3C;IAED,IAAI,YAAY,IAAI,oBAAoB,CAEvC;IAED,KAAK,sBAEJ;IAED,SAAS,sBA2BR;IAQD,sBAAsB,aAAc,GAAG,EAAE,SAUxC;IAGD,kBAAkB,CAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU;IAW9E,IAAI,WAAW,IAAI,QAAQ,CAsG1B;IAIK,cAAc,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAe/E"}
|
|
@@ -5,12 +5,12 @@ import { IInfluxDBManagerOptions, InstrumentPayload } from './../commonTypes';
|
|
|
5
5
|
import { ISubscriptionPayload, ISubscriptionKey } from '@nsshunt/stssocketio-client';
|
|
6
6
|
export declare class InfluxDBManagerAgent extends InfluxDBManagerBase {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi
|
|
8
|
+
constructor(options: IInfluxDBManagerOptions, queryApi: QueryApi);
|
|
9
9
|
get modelType(): string;
|
|
10
10
|
GetInfluxDBResultsRootAgent(subscriptionKey: ISubscriptionKey): Promise<ISubscriptionPayload>;
|
|
11
11
|
GetInfluxDBResultsAgent(subscriptionKey: ISubscriptionKey): Promise<ISubscriptionPayload>;
|
|
12
12
|
GetInfluxDBResultsAgentThreads(subscriptionKey: ISubscriptionKey): Promise<ISubscriptionPayload>;
|
|
13
13
|
GetInfluxDBResultsAgentThread(subscriptionKey: ISubscriptionKey): Promise<ISubscriptionPayload>;
|
|
14
|
-
OutputInfluxDB(instrumentPayload: InstrumentPayload): Promise<boolean>;
|
|
14
|
+
OutputInfluxDB(writeApi: WriteApi, instrumentPayload: InstrumentPayload): Promise<boolean>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=influxDBManagerAgent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerAgent.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerAgent.ts"],"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