From 4a3904fe4e9f19d73e845e3ddc9c35822f9cbe6e Mon Sep 17 00:00:00 2001 From: "fateme.r" Date: Sun, 13 Oct 2024 10:44:11 +0330 Subject: [PATCH 1/2] Add warn level to logger health parameter - Add new health parameter to check warn level log counts - Fix log level check to use the base logger instance not one of child instances - Tune log level check thresholds --- .changeset/angry-buttons-sniff.md | 5 +++++ config/default.yaml | 7 +++++-- src/config/config.ts | 6 ++++++ src/utils/healthCheck.ts | 11 ++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 .changeset/angry-buttons-sniff.md diff --git a/.changeset/angry-buttons-sniff.md b/.changeset/angry-buttons-sniff.md new file mode 100644 index 0000000..2559149 --- /dev/null +++ b/.changeset/angry-buttons-sniff.md @@ -0,0 +1,5 @@ +--- +'@rosen-bridge/watcher': minor +--- + +Add warn level to logger health parameter and tune the thresholds diff --git a/config/default.yaml b/config/default.yaml index 0e110ef..05b1af7 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -121,8 +121,11 @@ healthCheck: warnCommitmentCount: 4 # warning remaining permits for creating commitment criticalCommitmentCount: 0 # critical remaining permits for creating commitment errorLog: - maxAllowedCount: 2 # maximum allowed error log lines - duration: 100000 # error log duration time check in milliseconds + maxAllowedCount: 1 # maximum allowed error log lines + duration: 600000 # error log duration time check in milliseconds + warnLog: + maxAllowedCount: 10 # maximum allowed error log lines + duration: 600000 # error log duration time check in milliseconds redeemSwapEnabled: true # if set true when no permit left, system automatically redeem new commitments and commit again for old observations rewardCollection: threshold: 100000 # RSN threshold for reward collection diff --git a/src/config/config.ts b/src/config/config.ts index e3538b1..22b5fd1 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -528,6 +528,8 @@ class HealthCheckConfig { updateInterval: number; errorLogAllowedCount: number; errorLogDuration: number; + warnLogAllowedCount: number; + warnLogDuration: number; constructor() { this.ergWarnThreshold = BigInt( @@ -583,6 +585,10 @@ class HealthCheckConfig { 'healthCheck.errorLog.maxAllowedCount' ); this.errorLogDuration = getRequiredNumber('healthCheck.errorLog.duration'); + this.warnLogAllowedCount = getRequiredNumber( + 'healthCheck.warnLog.maxAllowedCount' + ); + this.warnLogDuration = getRequiredNumber('healthCheck.warnLog.duration'); } } diff --git a/src/utils/healthCheck.ts b/src/utils/healthCheck.ts index c972887..a1c4f8c 100644 --- a/src/utils/healthCheck.ts +++ b/src/utils/healthCheck.ts @@ -91,7 +91,7 @@ class HealthCheckSingleton { } this.healthCheck = new HealthCheck(notify, notificationConfig); const errorLogHealthCheck = new LogLevelHealthCheck( - logger, + WinstonLogger.getInstance().getDefaultLogger(), HealthStatusLevel.UNSTABLE, getConfig().healthCheck.errorLogAllowedCount, getConfig().healthCheck.errorLogDuration, @@ -99,6 +99,15 @@ class HealthCheckSingleton { ); this.healthCheck.register(errorLogHealthCheck); + const warnLogHealthCheck = new LogLevelHealthCheck( + WinstonLogger.getInstance().getDefaultLogger(), + HealthStatusLevel.UNSTABLE, + getConfig().healthCheck.warnLogAllowedCount, + getConfig().healthCheck.warnLogDuration, + 'warn' + ); + this.healthCheck.register(warnLogHealthCheck); + if (getConfig().general.scannerType === NODE_TYPE) { this.registerErgoNodeHealthCheckParams(); } else if (getConfig().general.scannerType === EXPLORER_TYPE) { From 18aeef29d139687b19a936eae909a72a50b4b729 Mon Sep 17 00:00:00 2001 From: "fateme.r" Date: Sun, 13 Oct 2024 13:36:37 +0330 Subject: [PATCH 2/2] improve logs health configuration --- config/default.yaml | 10 ++++------ src/config/config.ts | 10 ++++------ src/utils/healthCheck.ts | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/config/default.yaml b/config/default.yaml index 05b1af7..41048ca 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -120,12 +120,10 @@ healthCheck: permit: warnCommitmentCount: 4 # warning remaining permits for creating commitment criticalCommitmentCount: 0 # critical remaining permits for creating commitment - errorLog: - maxAllowedCount: 1 # maximum allowed error log lines - duration: 600000 # error log duration time check in milliseconds - warnLog: - maxAllowedCount: 10 # maximum allowed error log lines - duration: 600000 # error log duration time check in milliseconds + logs: + duration: 600 # log duration time check (in seconds) + maxAllowedErrorCount: 1 # maximum allowed error log lines + maxAllowedWarnCount: 10 # maximum allowed warn log lines redeemSwapEnabled: true # if set true when no permit left, system automatically redeem new commitments and commit again for old observations rewardCollection: threshold: 100000 # RSN threshold for reward collection diff --git a/src/config/config.ts b/src/config/config.ts index 22b5fd1..008cb8f 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -526,10 +526,9 @@ class HealthCheckConfig { permitCriticalCommitmentCount: number; permitDefaultCommitmentRWT: number; updateInterval: number; + logDuration: number; errorLogAllowedCount: number; - errorLogDuration: number; warnLogAllowedCount: number; - warnLogDuration: number; constructor() { this.ergWarnThreshold = BigInt( @@ -581,14 +580,13 @@ class HealthCheckConfig { 'healthCheck.permit.criticalCommitmentCount' ); this.updateInterval = getRequiredNumber('healthCheck.interval'); + this.logDuration = getRequiredNumber('healthCheck.logs.duration') * 1000; this.errorLogAllowedCount = getRequiredNumber( - 'healthCheck.errorLog.maxAllowedCount' + 'healthCheck.logs.maxAllowedErrorCount' ); - this.errorLogDuration = getRequiredNumber('healthCheck.errorLog.duration'); this.warnLogAllowedCount = getRequiredNumber( - 'healthCheck.warnLog.maxAllowedCount' + 'healthCheck.logs.maxAllowedWarnCount' ); - this.warnLogDuration = getRequiredNumber('healthCheck.warnLog.duration'); } } diff --git a/src/utils/healthCheck.ts b/src/utils/healthCheck.ts index a1c4f8c..4260552 100644 --- a/src/utils/healthCheck.ts +++ b/src/utils/healthCheck.ts @@ -94,7 +94,7 @@ class HealthCheckSingleton { WinstonLogger.getInstance().getDefaultLogger(), HealthStatusLevel.UNSTABLE, getConfig().healthCheck.errorLogAllowedCount, - getConfig().healthCheck.errorLogDuration, + getConfig().healthCheck.logDuration, 'error' ); this.healthCheck.register(errorLogHealthCheck); @@ -103,7 +103,7 @@ class HealthCheckSingleton { WinstonLogger.getInstance().getDefaultLogger(), HealthStatusLevel.UNSTABLE, getConfig().healthCheck.warnLogAllowedCount, - getConfig().healthCheck.warnLogDuration, + getConfig().healthCheck.logDuration, 'warn' ); this.healthCheck.register(warnLogHealthCheck);