update logs
This commit is contained in:
@ -269,6 +269,7 @@ export class LogDeduplicator {
|
||||
|
||||
private flushIPRejections(aggregated: IAggregatedEvent): void {
|
||||
const byIP = new Map<string, { count: number; reasons: Set<string> }>();
|
||||
const allReasons = new Map<string, number>();
|
||||
|
||||
for (const [ip, event] of aggregated.events) {
|
||||
if (!byIP.has(ip)) {
|
||||
@ -278,9 +279,17 @@ export class LogDeduplicator {
|
||||
ipData.count += event.count;
|
||||
if (event.data?.reason) {
|
||||
ipData.reasons.add(event.data.reason);
|
||||
// Track overall reason counts
|
||||
allReasons.set(event.data.reason, (allReasons.get(event.data.reason) || 0) + event.count);
|
||||
}
|
||||
}
|
||||
|
||||
// Create reason summary
|
||||
const reasonSummary = Array.from(allReasons.entries())
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.map(([reason, count]) => `${reason}: ${count}`)
|
||||
.join(', ');
|
||||
|
||||
// Log top offenders
|
||||
const topOffenders = Array.from(byIP.entries())
|
||||
.sort((a, b) => b[1].count - a[1].count)
|
||||
@ -291,7 +300,7 @@ export class LogDeduplicator {
|
||||
const totalRejections = Array.from(byIP.values()).reduce((sum, data) => sum + data.count, 0);
|
||||
|
||||
const duration = Date.now() - Math.min(...Array.from(aggregated.events.values()).map(e => e.firstSeen));
|
||||
logger.log('warn', `[SUMMARY] Rejected ${totalRejections} connections from ${byIP.size} IPs in ${Math.round(duration/1000)}s`, {
|
||||
logger.log('warn', `[SUMMARY] Rejected ${totalRejections} connections from ${byIP.size} IPs in ${Math.round(duration/1000)}s (${reasonSummary})`, {
|
||||
topOffenders,
|
||||
component: 'ip-dedup'
|
||||
});
|
||||
|
Reference in New Issue
Block a user