/** * Track 2E - Tool 5: LogDashboard * * Purpose: Create interactive log analysis dashboards with filtering, searching, and pattern detection. * * Operations: * 1. create - Create log dashboard * 2. update - Update dashboard configuration * 3. query - Query logs with filters * 4. aggregate - Aggregate log patterns * 5. detect-anomalies - Find unusual log patterns * 6. create-filter - Save custom log filter * 7. export - Export filtered logs * 8. tail - Real-time log streaming * * Token Reduction Target: 90% * Target Lines: 1,540 */ import { CacheEngine } from '../../core/cache-engine.js'; import { TokenCounter } from '../../core/token-counter.js'; import { MetricsCollector } from '../../core/metrics.js'; export interface LogDashboardOptions { operation: 'create' | 'update' | 'query' | 'aggregate' | 'detect-anomalies' | 'create-filter' | 'export' | 'tail'; dashboardId?: string; dashboardName?: string; logFiles?: string[]; logSources?: LogSource[]; query?: { pattern?: string; level?: LogLevel | LogLevel[]; timeRange?: { start: number; end: number; }; fields?: string[]; limit?: number; offset?: number; }; filterId?: string; filterName?: string; filter?: LogFilter; aggregation?: { groupBy?: string[]; timeWindow?: number; metrics?: Array<'count' | 'rate' | 'p50' | 'p95' | 'p99'>; }; anomaly?: { sensitivity?: number; method?: 'statistical' | 'ml' | 'pattern'; baselinePeriod?: number; }; format?: 'json' | 'csv' | 'txt'; outputPath?: string; follow?: boolean; lines?: number; useCache?: boolean; cacheTTL?: number; } export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'; export interface LogSource { id: string; name: string; type: 'file' | 'stream' | 'api' | 'database'; config: { path?: string; url?: string; query?: string; format?: 'json' | 'text' | 'syslog' | 'custom'; parser?: string; }; enabled: boolean; lastRead?: number; } export interface LogFilter { id: string; name: string; pattern?: string; level?: LogLevel[]; fields?: Record; exclude?: boolean; createdAt: number; } export interface LogEntry { timestamp: number; level: LogLevel; message: string; source?: string; fields?: Record; raw?: string; } export interface LogDashboardData { id: string; name: string; description?: string; sources: LogSource[]; filters: LogFilter[]; widgets: LogWidget[]; layout: DashboardLayout; createdAt: number; updatedAt: number; } export interface LogWidget { id: string; type: 'chart' | 'table' | 'timeline' | 'stats' | 'heatmap'; title: string; query: string; aggregation?: any; position: { x: number; y: number; w: number; h: number; }; } export interface DashboardLayout { type: 'grid' | 'flex'; columns: number; rowHeight: number; } export interface LogAggregation { groupKey: string; count: number; rate: number; timestamps: number[]; samples: LogEntry[]; } export interface LogAnomaly { timestamp: number; severity: 'low' | 'medium' | 'high' | 'critical'; type: string; description: string; baseline: number; actual: number; deviation: number; affectedLogs: LogEntry[]; } export interface LogDashboardResult { success: boolean; data?: { dashboard?: LogDashboardData; logs?: LogEntry[]; aggregations?: LogAggregation[]; anomalies?: LogAnomaly[]; filter?: LogFilter; stats?: { total: number; byLevel: Record; timeRange: { start: number; end: number; }; }; }; metadata: { tokensUsed?: number; tokensSaved?: number; cacheHit: boolean; logCount?: number; processingTime?: number; }; error?: string; } export declare class LogDashboard { private cache; private tokenCounter; private metricsCollector; private eventEmitter; private dashboards; private filtersMap; private logBuffer; private readonly maxLogBuffer; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector); /** * Main entry point for log dashboard operations */ run(options: LogDashboardOptions): Promise; private createDashboard; private updateDashboard; private queryLogs; private aggregateLogs; private detectAnomalies; private createFilter; private exportLogs; private tailLogs; private generateDashboardId; private generateFilterId; private findDashboardIdByName; private getCacheKey; private compressDashboardMetadata; private compressLogs; private readLogFile; private parseLogLine; private normalizeLogLevel; private applyFilters; private calculateStats; private performAggregation; private detectLogAnomalies; private calculateStdDev; private logsToCSV; private logsToText; private estimateQueryTokenSavings; private estimateAggregationTokenSavings; private estimateAnomalyTokenSavings; private persistDashboards; private persistFilters; private loadPersistedData; /** * Add log entry to buffer (for real-time logging) */ addLog(log: LogEntry): void; /** * Subscribe to log events */ onLog(callback: (log: LogEntry) => void): void; } export declare function getLogDashboard(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector): LogDashboard; export declare const LOG_DASHBOARD_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { operation: { type: string; enum: string[]; description: string; }; dashboardId: { type: string; description: string; }; dashboardName: { type: string; description: string; }; logFiles: { type: string; items: { type: string; }; description: string; }; query: { type: string; description: string; properties: { pattern: { type: string; }; level: { type: string[]; items: { type: string; }; }; timeRange: { type: string; properties: { start: { type: string; }; end: { type: string; }; }; }; limit: { type: string; }; offset: { type: string; }; }; }; aggregation: { type: string; description: string; properties: { groupBy: { type: string; items: { type: string; }; }; timeWindow: { type: string; }; metrics: { type: string; items: { type: string; }; }; }; }; anomaly: { type: string; description: string; properties: { sensitivity: { type: string; }; method: { type: string; }; baselinePeriod: { type: string; }; }; }; filterName: { type: string; description: string; }; format: { type: string; enum: string[]; description: string; }; outputPath: { type: string; description: string; }; follow: { type: string; description: string; }; lines: { type: string; description: string; }; useCache: { type: string; description: string; default: boolean; }; logSources: { type: string; description: string; items: { type: string; properties: { id: { type: string; }; name: { type: string; }; type: { type: string; enum: string[]; }; config: { type: string; description: string; properties: { path: { type: string; }; url: { type: string; }; query: { type: string; }; format: { type: string; enum: string[]; }; parser: { type: string; description: string; }; }; }; enabled: { type: string; description: string; }; lastRead: { type: string; description: string; }; }; required: string[]; }; }; filterId: { type: string; description: string; }; filter: { type: string; description: string; properties: { id: { type: string; }; name: { type: string; }; pattern: { type: string; description: string; }; level: { type: string; items: { type: string; }; description: string; }; fields: { type: string; additionalProperties: boolean; }; exclude: { type: string; description: string; default: boolean; }; createdAt: { type: string; description: string; }; }; required: string[]; }; cacheTTL: { type: string; description: string; }; }; required: string[]; }; }; //# sourceMappingURL=log-dashboard.d.ts.map