@ahmedhegazee/nestjs-telescope
Version:
Advanced observability and monitoring solution for NestJS applications with ML-powered analytics, enterprise features, and production-ready scaling
155 lines (154 loc) • 5.52 kB
TypeScript
/// <reference types="node" />
import { Observable } from 'rxjs';
import { MLAnalyticsService, AnomalyDetection, RegressionAnalysis, QueryOptimizationSuggestion, PredictiveInsight, MLAlert } from '../../core/services/ml-analytics.service';
import { AutomatedAlertingService, AlertChannel, AlertRule, AlertHistory, AlertMetrics } from '../../core/services/automated-alerting.service';
export declare class AnomalyQueryDto {
component?: string;
severity?: 'low' | 'medium' | 'high' | 'critical';
type?: 'performance' | 'error' | 'traffic' | 'resource' | 'query';
limit?: number;
from?: Date;
to?: Date;
}
export declare class AlertChannelDto {
name: string;
type: 'email' | 'slack' | 'teams' | 'webhook' | 'sms' | 'pagerduty';
enabled?: boolean;
config: {
url?: string;
token?: string;
email?: string;
phone?: string;
[key: string]: any;
};
severityFilter?: ('info' | 'warning' | 'error' | 'critical')[];
componentFilter?: string[];
rateLimit?: {
maxAlerts: number;
timeWindow: number;
};
}
export declare class AlertRuleDto {
name: string;
description: string;
enabled?: boolean;
priority?: number;
conditions: Array<{
metric: string;
operator: '>' | '<' | '==' | '!=' | '>=' | '<=';
threshold: number;
duration?: number;
component?: string;
}>;
actions: {
channelIds: string[];
escalation?: {
delayMinutes: number;
channels: string[];
};
autoRemediation?: {
enabled: boolean;
actions: Array<{
type: 'restart' | 'scale' | 'rollback' | 'cache_clear';
config: any;
}>;
};
};
schedule?: {
timezone: string;
activeHours: {
start: string;
end: string;
};
activeDays: number[];
};
}
export declare class MLInsightSummary {
timestamp: Date;
anomaliesCount: number;
regressionsCount: number;
optimizationsCount: number;
predictionsCount: number;
alertsCount: number;
healthScore: number;
riskLevel: 'low' | 'medium' | 'high' | 'critical';
topConcerns: Array<{
type: string;
component: string;
severity: string;
description: string;
}>;
}
export declare class Week8MLAnalyticsController {
private readonly mlAnalyticsService;
private readonly alertingService;
constructor(mlAnalyticsService: MLAnalyticsService, alertingService: AutomatedAlertingService);
getMLOverview(): Promise<MLInsightSummary>;
getAnomalies(query: AnomalyQueryDto): AnomalyDetection[];
getAnomaliesStream(): Observable<AnomalyDetection[]>;
dismissAnomaly(anomalyId: string): boolean;
getRegressions(component?: string, trend?: 'improving' | 'degrading' | 'stable', limit?: number): RegressionAnalysis[];
getRegressionsStream(): Observable<RegressionAnalysis[]>;
getOptimizations(table?: string, type?: 'index' | 'rewrite' | 'cache' | 'partition' | 'normalize', effort?: 'low' | 'medium' | 'high', limit?: number): QueryOptimizationSuggestion[];
getOptimizationsStream(): Observable<QueryOptimizationSuggestion[]>;
getPredictions(component?: string, predictionType?: 'load' | 'failure' | 'performance' | 'resource', timeHorizon?: '1h' | '6h' | '24h' | '7d' | '30d', riskLevel?: 'low' | 'medium' | 'high' | 'critical', limit?: number): PredictiveInsight[];
getPredictionsStream(): Observable<PredictiveInsight[]>;
getMLMetrics(): {
anomaliesDetected: number;
regressionsAnalyzed: number;
optimizationSuggestions: number;
predictiveInsights: number;
activeAlerts: number;
dataHistorySize: number;
};
getMLAlerts(severity?: 'info' | 'warning' | 'error' | 'critical', type?: 'anomaly' | 'regression' | 'prediction' | 'optimization', limit?: number): MLAlert[];
getMLAlertsStream(): Observable<MLAlert[]>;
acknowledgeMLAlert(alertId: string): {
success: boolean;
alertId: string;
acknowledgedAt: Date;
};
getAlertChannels(): AlertChannel[];
createAlertChannel(channelDto: AlertChannelDto): {
success: boolean;
channel: AlertChannel;
};
deleteAlertChannel(channelId: string): void;
testAlertChannel(channelId: string): Promise<{
success: boolean;
message: any;
}>;
getAlertRules(): AlertRule[];
createAlertRule(ruleDto: AlertRuleDto): {
success: boolean;
rule: AlertRule;
};
deleteAlertRule(ruleId: string): void;
getAlertHistory(limit?: number): AlertHistory[];
getAlertHistoryStream(): Observable<AlertHistory>;
getAlertMetrics(): AlertMetrics;
acknowledgeHistoryAlert(alertId: string): {
success: boolean;
alertId: string;
acknowledgedAt: Date;
};
getDashboardSummary(): Promise<{
timestamp: Date;
overview: MLInsightSummary;
alerting: AlertMetrics;
mlEngine: {
anomaliesDetected: number;
regressionsAnalyzed: number;
optimizationSuggestions: number;
predictiveInsights: number;
activeAlerts: number;
dataHistorySize: number;
};
system: {
uptime: number;
memoryUsage: NodeJS.MemoryUsage;
version: string;
};
}>;
getLiveFeed(): Observable<any>;
}