/** * Comprehensive Monitoring and Alerting System * * Provides real-time monitoring of system performance, resource usage, * and health metrics with configurable alerting thresholds. */ import { EventEmitter } from 'events'; import { CircuitBreakerStats } from './circuitBreaker.js'; export interface MonitoringConfig { enabled: boolean; metricsInterval?: number; retentionPeriod?: number; alertThresholds?: AlertThresholds; alertChannels?: AlertChannel[]; } export interface AlertThresholds { errorRate?: number; responseTime?: number; memoryUsage?: number; cpuUsage?: number; connectionPoolUsage?: number; circuitBreakerFailures?: number; } export interface AlertChannel { type: 'console' | 'file' | 'webhook' | 'email'; config: Record; } export interface SystemMetrics { timestamp: number; memory: { used: number; total: number; percentage: number; }; cpu: { usage: number; }; requests: { total: number; success: number; error: number; errorRate: number; avgResponseTime: number; }; connectionPools: Record; circuitBreakers: Record; } export interface Alert { id: string; timestamp: number; severity: 'low' | 'medium' | 'high' | 'critical'; type: string; message: string; metrics: Partial; resolved: boolean; resolvedAt?: number; } export interface MonitoringDashboard { uptime: number; totalRequests: number; totalErrors: number; currentErrorRate: number; avgResponseTime: number; activeAlerts: number; systemHealth: 'healthy' | 'degraded' | 'critical'; } /** * Advanced monitoring system with alerting */ export declare class MonitoringSystem extends EventEmitter { private config; private metrics; private alerts; private metricsInterval?; private startTime; private requestMetrics; private healthHistory; constructor(config?: MonitoringConfig); /** * Record a request for metrics tracking */ recordRequest(responseTime: number, success: boolean): void; /** * Get current dashboard metrics */ getDashboard(): MonitoringDashboard; /** * Get metrics history */ getMetricsHistory(limit?: number): SystemMetrics[]; /** * Get active alerts */ getActiveAlerts(): Alert[]; /** * Get all alerts */ getAllAlerts(): Alert[]; /** * Resolve an alert */ resolveAlert(alertId: string): void; /** * Gracefully shutdown monitoring */ shutdown(): Promise; private startMonitoring; private collectMetrics; private gatherSystemMetrics; private checkAlerts; private createAlert; private isDuplicateAlert; private sendAlert; private sendFileAlert; private sendWebhookAlert; private getLatestMetrics; } /** * Global monitoring instance */ export declare const monitoringSystem: MonitoringSystem; export default MonitoringSystem; //# sourceMappingURL=monitoring.d.ts.map