import { monitoringSchedule } from '../shared/monitoring/monitoring-config'; // Example of how to use configurable monitoring thresholds in your application export class MonitoringThresholds { // Check if invalid login attempts exceed threshold static shouldAlertInvalidLogins(attempts: number): boolean { return attempts >= monitoringSchedule.invalidLoginThreshold; } // Check if memory usage exceeds threshold static shouldAlertMemoryUsage(usagePercent: number): boolean { return usagePercent > monitoringSchedule.memoryAlertThreshold; } // Check if API failure rate exceeds threshold static shouldAlertApiFailures(failureRate: number): boolean { return failureRate > monitoringSchedule.apiFailureAlertThreshold; } // Get current thresholds for logging/debugging static getCurrentThresholds() { return { memoryAlert: `${monitoringSchedule.memoryAlertThreshold}%`, apiFailureAlert: `${monitoringSchedule.apiFailureAlertThreshold}%`, invalidLoginAlert: `${monitoringSchedule.invalidLoginThreshold} per hour`, healthCheckInterval: `${monitoringSchedule.healthCheckInterval} minutes`, dailyReportTime: `${monitoringSchedule.dailyReportTime} UTC`, logCleanupInterval: `${monitoringSchedule.logCleanupInterval} hours`, logRetention: `${monitoringSchedule.logRetentionDays} days` }; } } // Example usage in auth handler: /* import { MonitoringThresholds } from '../utils/monitoring-thresholds.example'; // In your trackInvalidLoginAttempt method: if (MonitoringThresholds.shouldAlertInvalidLogins(attempts.count)) { this.logger.warn(`Multiple failed login attempts detected`, chatId, { attempts: attempts.count, threshold: monitoringSchedule.invalidLoginThreshold, timeWindow: '1 hour' }); } */ // Example usage in health checks: /* const memUsagePercent = (memUsage.heapUsed / memUsage.heapTotal) * 100; if (MonitoringThresholds.shouldAlertMemoryUsage(memUsagePercent)) { issues.push(`High memory usage: ${memUsagePercent.toFixed(1)}% (threshold: ${monitoringSchedule.memoryAlertThreshold}%)`); } */