@@ -27,9 +27,9 @@ class LogProcessor {
27
27
this . logPatterns = new Map ( ) ; // Track repeated log patterns
28
28
this . consolidationTimers = new Map ( ) ; // Timers for sending consolidation summaries
29
29
this . consolidationConfig = {
30
- minRepeatCount : 3 , // Minimum repeats before consolidating
31
- consolidationDelay : 30000 , // 30 seconds delay before sending summary
32
- summaryTimeout : 300000 , // 5 minutes timeout for "stopped" message
30
+ minRepeatCount : 10 , // Minimum repeats before consolidating
31
+ consolidationDelay : 120000 , // 2 minutes delay before sending summary
32
+ summaryTimeout : 900000 , // 15 minutes timeout for "stopped" message
33
33
enableStoppedMessages : true // Whether to send "stopped" messages
34
34
} ;
35
35
}
@@ -468,43 +468,34 @@ class LogProcessor {
468
468
trackLogPattern ( streamKey , line , config , slackService ) {
469
469
const pattern = this . extractLogPattern ( line ) ;
470
470
const patternKey = this . getPatternKey ( streamKey , pattern ) ;
471
-
472
- if ( ! this . logPatterns . has ( patternKey ) ) {
473
- this . logPatterns . set ( patternKey , {
471
+ let patternData = this . logPatterns . get ( patternKey ) ;
472
+ if ( ! patternData ) {
473
+ patternData = {
474
474
pattern,
475
- streamKey,
476
- config,
477
- slackService,
478
475
count : 0 ,
479
- firstSeen : Date . now ( ) ,
480
- lastSeen : Date . now ( ) ,
481
476
isConsolidated : false ,
477
+ isSuppressed : false , // NEW: suppress after first summary until resolved
478
+ lastSeen : Date . now ( ) ,
479
+ config,
480
+ slackService,
482
481
consolidationTimer : null ,
483
482
stoppedTimer : null
484
- } ) ;
483
+ } ;
484
+ this . logPatterns . set ( patternKey , patternData ) ;
485
485
}
486
-
487
- const patternData = this . logPatterns . get ( patternKey ) ;
488
- patternData . count ++ ;
489
486
patternData . lastSeen = Date . now ( ) ;
490
-
491
- // Clear any existing stopped timer since we're seeing the pattern again
492
- if ( patternData . stoppedTimer ) {
493
- clearTimeout ( patternData . stoppedTimer ) ;
494
- patternData . stoppedTimer = null ;
495
- }
496
-
497
- // Start consolidation if we haven't already and we meet the threshold
498
- if ( ! patternData . isConsolidated && patternData . count >= this . consolidationConfig . minRepeatCount ) {
499
- this . startConsolidation ( patternKey , patternData ) ;
487
+ if ( ! patternData . isSuppressed ) {
488
+ patternData . count ++ ;
489
+ if ( ! patternData . isConsolidated && patternData . count >= this . consolidationConfig . minRepeatCount ) {
490
+ this . startConsolidation ( patternKey , patternData ) ;
491
+ patternData . isConsolidated = true ;
492
+ patternData . isSuppressed = true ; // Suppress further reporting until resolved
493
+ }
500
494
}
501
-
502
495
return patternData ;
503
496
}
504
497
505
498
startConsolidation ( patternKey , patternData ) {
506
- patternData . isConsolidated = true ;
507
-
508
499
// Clear any existing timer
509
500
if ( patternData . consolidationTimer ) {
510
501
clearTimeout ( patternData . consolidationTimer ) ;
@@ -519,27 +510,24 @@ class LogProcessor {
519
510
async sendConsolidationSummary ( patternKey , patternData ) {
520
511
try {
521
512
const message = this . formatConsolidationMessage ( patternData ) ;
522
-
523
513
await patternData . slackService . sendMessage (
524
514
patternData . config . channel ,
525
515
message ,
526
516
patternData . config
527
517
) ;
528
-
529
518
this . logger . debug ( `Sent consolidation summary for pattern: ${ patternData . pattern } ` ) ;
530
-
531
- // Reset count and start tracking for next consolidation
519
+ // Reset count but keep suppressed until resolved
532
520
patternData . count = 0 ;
533
521
patternData . isConsolidated = false ;
522
+ // patternData.isSuppressed remains true until stopped message
534
523
patternData . consolidationTimer = null ;
535
-
536
524
} catch ( error ) {
537
525
this . logger . error ( `Failed to send consolidation summary for ${ patternKey } ` , error ) ;
538
526
}
539
527
}
540
528
541
529
formatConsolidationMessage ( patternData ) {
542
- const duration = Math . round ( ( Date . now ( ) - patternData . firstSeen ) / 1000 ) ;
530
+ const duration = Math . round ( ( Date . now ( ) - patternData . lastSeen ) / 1000 ) ;
543
531
const level = this . extractLogLevel ( patternData . pattern ) ;
544
532
const baseInfo = `${ patternData . config . podName } (${ patternData . config . namespace } )` ;
545
533
@@ -591,18 +579,15 @@ class LogProcessor {
591
579
async sendStoppedMessage ( patternKey , patternData ) {
592
580
try {
593
581
const message = this . formatStoppedMessage ( patternData ) ;
594
-
595
582
await patternData . slackService . sendMessage (
596
583
patternData . config . channel ,
597
584
message ,
598
585
patternData . config
599
586
) ;
600
-
601
587
this . logger . debug ( `Sent stopped message for pattern: ${ patternData . pattern } ` ) ;
602
-
603
- // Remove the pattern from tracking
588
+ // Remove the pattern from tracking and allow it to be reported again
604
589
this . logPatterns . delete ( patternKey ) ;
605
-
590
+ // (If you want to keep the object for stats, you could instead reset isSuppressed)
606
591
} catch ( error ) {
607
592
this . logger . error ( `Failed to send stopped message for ${ patternKey } ` , error ) ;
608
593
}
0 commit comments