feat(alerts): add MasterID to log records and improve traffic spike detection

- Add MasterID field with index to LogRecord model for efficient queries
- Fix threshold config loading to use fixed ID=1 with FirstOrCreate
- Allow traffic spike detection to work without Redis for log-based checks
- Add traffic_spike to API documentation for alert type filter
- Add comprehensive tests for RPM/RPD/TPM spike detection scenarios
This commit is contained in:
zenfun
2025-12-31 18:01:09 +08:00
parent f714a314a9
commit 4cda273f7b
4 changed files with 324 additions and 24 deletions

View File

@@ -6,6 +6,7 @@ import "gorm.io/gorm"
type LogRecord struct {
gorm.Model
Group string `json:"group"`
MasterID uint `gorm:"index" json:"master_id"`
KeyID uint `json:"key_id"`
ModelName string `json:"model"`
ProviderID uint `json:"provider_id"`