Add Telegram bot integration for real-time alert notifications
- Implemented ITelegramNotificationService and TelegramNotificationService for sending alerts via Telegram. - Updated MonitoringSettings to include Telegram configuration options. - Enhanced AlertService to send alerts and resolutions through Telegram. - Added API endpoints for checking Telegram status and sending test alerts. - Updated README and TELEGRAM_SETUP.md with setup instructions and features. - Included example configuration in appsettings.telegram.example.json.
This commit is contained in:
@@ -38,6 +38,8 @@ namespace ResourceMonitorService.Configuration
|
||||
new() { Component = "CPUTemp", WarningThreshold = 75, CriticalThreshold = 85, DurationSeconds = 60 },
|
||||
new() { Component = "GPUTemp", WarningThreshold = 80, CriticalThreshold = 90, DurationSeconds = 60 }
|
||||
};
|
||||
|
||||
public TelegramSettings Telegram { get; set; } = new();
|
||||
}
|
||||
|
||||
public class AlertThresholdConfig
|
||||
@@ -73,4 +75,16 @@ namespace ResourceMonitorService.Configuration
|
||||
public bool EnableConsoleLogging { get; set; } = true;
|
||||
public bool EnablePerformanceLogging { get; set; } = false;
|
||||
}
|
||||
|
||||
public class TelegramSettings
|
||||
{
|
||||
public bool IsEnabled { get; set; } = false;
|
||||
public string BotToken { get; set; } = string.Empty;
|
||||
public List<long> ChatIds { get; set; } = new();
|
||||
public bool SendWarningAlerts { get; set; } = true;
|
||||
public bool SendCriticalAlerts { get; set; } = true;
|
||||
public bool SendResolutionNotifications { get; set; } = true;
|
||||
public string MessageTemplate { get; set; } = "🚨 *{Level} Alert*\n\n📊 *{Component}*\n💬 {Message}\n⏰ {Timestamp:yyyy-MM-dd HH:mm:ss}";
|
||||
public string ResolutionTemplate { get; set; } = "✅ *Alert Resolved*\n\n📊 *{Component}*\n💬 {Message}\n⏰ Resolved at {ResolvedAt:yyyy-MM-dd HH:mm:ss}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user