/** * Alert System * * Configure and trigger alerts based on metrics and thresholds */ export type AlertSeverity = 'info' | 'warning' | 'error' | 'critical'; export type AlertStatus = 'firing' | 'resolved'; export interface Alert { id: string; name: string; severity: AlertSeverity; status: AlertStatus; message: string; details?: Record; timestamp: string; resolvedAt?: string; labels?: Record; } export interface AlertRule { name: string; severity: AlertSeverity; condition: () => boolean | Promise; message: string | ((context: Record) => string); labels?: Record; cooldown?: number; enabled?: boolean; } export interface AlertChannel { name: string; send: (alert: Alert) => Promise; severities?: AlertSeverity[]; } export declare class AlertingSystem { private rules; private channels; private activeAlerts; private lastFired; /** * Register alert rule */ registerRule(rule: AlertRule): void; /** * Unregister alert rule */ unregisterRule(name: string): void; /** * Add alert channel */ addChannel(channel: AlertChannel): void; /** * Evaluate all rules */ evaluateRules(): Promise; /** * Fire an alert */ private fireAlert; /** * Resolve an alert */ private resolveAlert; /** * Send alert to channels */ private sendAlert; /** * Get active alerts */ getActiveAlerts(): Alert[]; /** * Get alert by name */ getAlert(name: string): Alert | undefined; /** * Start monitoring */ startMonitoring(intervalMs?: number): NodeJS.Timeout; } /** * Default alerting system */ export declare const alerting: AlertingSystem; /** * Console alert channel */ export declare const consoleChannel: AlertChannel; /** * Webhook alert channel */ export declare function createWebhookChannel(url: string, severities?: AlertSeverity[]): AlertChannel; /** * Email alert channel */ export declare function createEmailChannel(sendEmailFn: (to: string, subject: string, body: string) => Promise, recipients: string[], severities?: AlertSeverity[]): AlertChannel; /** * Slack alert channel */ export declare function createSlackChannel(webhookUrl: string, severities?: AlertSeverity[]): AlertChannel; /** * Common alert rules */ /** * High error rate alert */ export declare function createErrorRateAlert(getErrorRate: () => number, threshold?: number): AlertRule; /** * High response time alert */ export declare function createResponseTimeAlert(getP95: () => number, threshold?: number): AlertRule; /** * Low cache hit rate alert */ export declare function createCacheHitRateAlert(getCacheHitRate: () => number, threshold?: number): AlertRule; /** * High memory usage alert */ export declare function createMemoryUsageAlert(getMemoryUsage: () => number, threshold?: number): AlertRule; /** * Database connection alert */ export declare function createDatabaseAlert(checkConnection: () => Promise): AlertRule; /** * Service health alert */ export declare function createServiceHealthAlert(serviceName: string, checkHealth: () => Promise): AlertRule; /** * Disk space alert */ export declare function createDiskSpaceAlert(getDiskUsage: () => number, threshold?: number): AlertRule; /** * Queue size alert */ export declare function createQueueSizeAlert(queueName: string, getQueueSize: () => number, threshold?: number): AlertRule; /** * Custom metric alert */ export declare function createMetricAlert(name: string, getMetric: () => number, threshold: number, operator?: '>' | '<' | '=', severity?: AlertSeverity): AlertRule; //# sourceMappingURL=alerts.d.ts.map