UNPKG

@hivetechs/hive-ai

Version:

Real-time streaming AI consensus platform with HTTP+SSE MCP integration for Claude Code, VS Code, Cursor, and Windsurf - powered by OpenRouter's unified API

250 lines 6.12 kB
/** * Advanced Alerting System - Expert-level monitoring and alerting * * Provides intelligent alerting with smart thresholds, anomaly detection, * and customizable alert rules for production monitoring. */ export interface AlertRule { id: string; name: string; description: string; enabled: boolean; category: 'performance' | 'cost' | 'quality' | 'availability' | 'security'; severity: 'low' | 'medium' | 'high' | 'critical'; condition: AlertCondition; actions: AlertAction[]; throttle: { enabled: boolean; windowMinutes: number; maxAlerts: number; }; createdAt: string; updatedAt: string; triggeredCount: number; lastTriggered?: string; } export interface AlertCondition { type: 'threshold' | 'anomaly' | 'trend' | 'composite'; metric: string; operator: '>' | '<' | '=' | '>=' | '<=' | '!=' | 'contains' | 'regex'; value: number | string; windowMinutes?: number; aggregation?: 'avg' | 'sum' | 'min' | 'max' | 'count'; conditions?: AlertCondition[]; logic?: 'AND' | 'OR'; } export interface AlertAction { type: 'log' | 'webhook' | 'email' | 'slack' | 'circuit_breaker' | 'auto_scale'; config: Record<string, any>; enabled: boolean; } export interface Alert { id: string; ruleId: string; ruleName: string; severity: 'low' | 'medium' | 'high' | 'critical'; message: string; details: Record<string, any>; timestamp: string; resolved: boolean; resolvedAt?: string; acknowledged: boolean; acknowledgedAt?: string; acknowledgedBy?: string; } export interface AlertingConfig { enabled: boolean; defaultThresholds: { responseTime: number; errorRate: number; costSpike: number; qualityDrop: number; }; anomalyDetection: { enabled: boolean; sensitivity: 'low' | 'medium' | 'high'; learningPeriodDays: number; }; notifications: { webhook?: { url: string; headers: Record<string, string>; }; slack?: { webhookUrl: string; channel: string; }; email?: { smtp: { host: string; port: number; secure: boolean; auth: { user: string; pass: string; }; }; recipients: string[]; }; }; } export declare class AdvancedAlerting { private rules; private alerts; private config; private anomalyBaselines; private throttleTracker; constructor(config?: Partial<AlertingConfig>); /** * Initialize default alert rules */ private initializeDefaultRules; /** * Add new alert rule */ addRule(rule: Omit<AlertRule, 'id' | 'createdAt' | 'updatedAt' | 'triggeredCount'>): string; /** * Update existing alert rule */ updateRule(id: string, updates: Partial<AlertRule>): boolean; /** * Remove alert rule */ removeRule(id: string): boolean; /** * Get all alert rules */ getRules(): AlertRule[]; /** * Start monitoring for alerts */ private startMonitoring; /** * Check all rules against current metrics */ private checkAlerts; /** * Evaluate a single alert rule */ private evaluateRule; /** * Evaluate alert condition against metrics */ private evaluateCondition; /** * Evaluate threshold-based condition */ private evaluateThresholdCondition; /** * Evaluate anomaly-based condition */ private evaluateAnomalyCondition; /** * Evaluate trend-based condition */ private evaluateTrendCondition; /** * Evaluate composite condition */ private evaluateCompositeCondition; /** * Extract metric values from performance metrics */ private extractMetricValues; /** * Get nested value from object using dot notation */ private getNestedValue; /** * Fire an alert */ private fireAlert; /** * Execute alert actions */ private executeAlertActions; /** * Execute individual alert action */ private executeAction; /** * Send webhook notification */ private sendWebhook; /** * Send Slack notification */ private sendSlackNotification; /** * Check if rule is throttled */ private isThrottled; /** * Update throttle tracker */ private updateThrottleTracker; /** * Get recent metrics for evaluation */ private getRecentMetrics; /** * Get anomaly baseline for metric */ private getAnomalyBaseline; /** * Update anomaly baseline */ private updateAnomalyBaseline; /** * Calculate standard deviation */ private calculateStandardDeviation; /** * Generate alert message */ private generateAlertMessage; /** * Public API methods */ /** * Acknowledge alert */ acknowledgeAlert(alertId: string, acknowledgedBy: string): boolean; /** * Resolve alert */ resolveAlert(alertId: string): boolean; /** * Get all alerts */ getAlerts(filter?: { severity?: string; resolved?: boolean; acknowledged?: boolean; since?: string; }): Alert[]; /** * Get alerting statistics */ getAlertingStats(): { totalRules: number; enabledRules: number; totalAlerts: number; alertsBySeverity: Record<string, number>; unresolvedAlerts: number; alertsLast24h: number; }; /** * Update alerting configuration */ updateConfig(newConfig: Partial<AlertingConfig>): void; /** * Get current configuration */ getConfig(): AlertingConfig; } /** * Global advanced alerting instance */ export declare const globalAdvancedAlerting: AdvancedAlerting; //# sourceMappingURL=advanced-alerting.d.ts.map