anon-identity
Version:
Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure
236 lines • 5.85 kB
TypeScript
/**
* MCP Monitoring Dashboard
*
* Comprehensive monitoring and analytics for LLM interactions
*/
import { EventEmitter } from 'events';
import { ProviderHealth, ProviderMetrics, RequestPriority, LLMRequestType } from '../types';
import { MessageRouter } from '../routing/message-router';
import { ProviderSelector } from '../providers/provider-selector';
import { ContextManager } from '../context/context-manager';
import { StreamManager } from '../streaming/stream-manager';
import { AgentMatcher } from '../matching/agent-matcher';
import { AuditLogger } from '../security/audit-logger';
import { RateLimiterManager } from '../security/rate-limiter';
/**
* Dashboard metric types
*/
export interface DashboardMetrics {
totalRequests: number;
totalTokens: number;
totalCost: number;
averageLatency: number;
errorRate: number;
providerHealth: ProviderHealth[];
providerUsage: Record<string, ProviderMetrics>;
requestsByType: Record<LLMRequestType, number>;
requestsByPriority: Record<RequestPriority, number>;
requestsByAgent: Record<string, number>;
latencyPercentiles: {
p50: number;
p90: number;
p95: number;
p99: number;
};
costByProvider: Record<string, number>;
costByAgent: Record<string, number>;
costByRequestType: Record<LLMRequestType, number>;
activeContexts: number;
totalContextTokens: number;
compressionsSaved: number;
activeStreams: number;
totalStreamedTokens: number;
averageStreamLatency: number;
totalMatches: number;
matchSuccessRate: number;
averageMatchScore: number;
}
/**
* Time series data point
*/
export interface TimeSeriesDataPoint {
timestamp: Date;
value: number;
metadata?: Record<string, any>;
}
/**
* Alert configuration
*/
export interface AlertConfig {
metric: string;
threshold: number;
operator: 'gt' | 'lt' | 'eq' | 'gte' | 'lte';
windowSize: number;
cooldown: number;
}
/**
* Dashboard configuration
*/
export interface DashboardConfig {
refreshInterval: number;
retentionPeriod: number;
alerts: AlertConfig[];
enableRealTimeUpdates: boolean;
enableHistoricalAnalysis: boolean;
exportFormats: ('json' | 'csv' | 'prometheus')[];
}
/**
* MCP Monitoring Dashboard
*/
export declare class MCPMonitoringDashboard extends EventEmitter {
private messageRouter;
private providerSelector;
private contextManager;
private streamManager;
private agentMatcher;
private auditLogger;
private rateLimiter;
private config;
private metrics;
private timeSeries;
private activeAlerts;
private refreshTimer?;
private metricsHistory;
constructor(messageRouter: MessageRouter, providerSelector: ProviderSelector | null, contextManager: ContextManager, streamManager: StreamManager, agentMatcher: AgentMatcher, auditLogger: AuditLogger, rateLimiter: RateLimiterManager, config?: DashboardConfig);
/**
* Initialize empty metrics
*/
private initializeMetrics;
/**
* Setup event listeners
*/
private setupEventListeners;
/**
* Start metrics collection
*/
private startMetricsCollection;
/**
* Collect current metrics
*/
private collectMetrics;
/**
* Update metric value
*/
private updateMetric;
/**
* Update request breakdown
*/
private updateRequestBreakdown;
/**
* Update latency metrics
*/
private updateLatencyMetrics;
/**
* Update cost metrics
*/
private updateCostMetrics;
/**
* Update error rate
*/
private updateErrorRate;
/**
* Update provider usage
*/
private updateProviderUsage;
/**
* Update provider performance
*/
private updateProviderPerformance;
/**
* Update stream latency
*/
private updateStreamLatency;
/**
* Record compression savings
*/
private recordCompressionSavings;
/**
* Update match metrics
*/
private updateMatchMetrics;
/**
* Update match success rate
*/
private updateMatchSuccessRate;
/**
* Get rate limiter statistics
*/
private getRateLimiterStats;
/**
* Calculate derived metrics
*/
private calculateDerivedMetrics;
/**
* Get percentile value
*/
private getPercentile;
/**
* Record time series data
*/
private recordTimeSeries;
/**
* Check alerts
*/
private checkAlerts;
/**
* Get metric value by path
*/
private getMetricValue;
/**
* Evaluate alert condition
*/
private evaluateAlertCondition;
/**
* Store historical data
*/
private storeHistoricalData;
/**
* Get current metrics
*/
getMetrics(): DashboardMetrics;
/**
* Get time series data
*/
getTimeSeries(metric: string, duration?: number): TimeSeriesDataPoint[];
/**
* Get active alerts
*/
getActiveAlerts(): Array<{
alert: AlertConfig;
triggered: Date;
}>;
/**
* Export metrics
*/
exportMetrics(format?: 'json' | 'csv' | 'prometheus'): string;
/**
* Export as CSV
*/
private exportAsCSV;
/**
* Export as Prometheus metrics
*/
private exportAsPrometheus;
/**
* Add custom alert
*/
addAlert(alert: AlertConfig): void;
/**
* Remove alert
*/
removeAlert(metric: string): void;
/**
* Get historical metrics
*/
getHistoricalMetrics(duration?: number): DashboardMetrics[];
/**
* Reset metrics
*/
resetMetrics(): void;
/**
* Shutdown dashboard
*/
shutdown(): void;
}
export default MCPMonitoringDashboard;
//# sourceMappingURL=mcp-monitoring-dashboard.d.ts.map