feat(monitor): F6 日志告警引擎 — AlertEngine 支持 type=log 规则查询Loki/ES+触发/恢复 + 数据源认证升级(none/basic/bearer/custom) + 从查询创建告警真实API对接

This commit is contained in:
attacker committed 2026-06-28 04:00:38 +08:00
1 parent 894cb16a05
commit 6bba6144f3
17 files changed
+657 -74

No files matched your search

+13 -1
View File
@@ -11,9 +11,12 @@ type LogDataSource struct {
Name string `gorm:"type:varchar(128);not null;uniqueIndex;comment:数据源名称" json:"name"`
Type string `gorm:"type:varchar(32);not null;index;comment:类型 loki/elasticsearch" json:"type"`
URL string `gorm:"type:varchar(512);not null;comment:服务地址" json:"url"`
BasicAuth bool `gorm:"default:false;comment:基础认证" json:"basic_auth"`
AuthType string `gorm:"type:varchar(32);default:'none';comment:认证方式 none/basic/bearer/custom" json:"auth_type"`
BasicAuth bool `gorm:"default:false;comment:基础认证(兼容旧版)" json:"basic_auth"`
BasicAuthUser string `gorm:"type:varchar(128);comment:认证用户名" json:"basic_auth_user,omitempty"`
BasicAuthPass string `gorm:"type:varchar(256);comment:认证密码" json:"basic_auth_pass,omitempty"`
Token string `gorm:"type:varchar(512);comment:Bearer Token" json:"token,omitempty"`
Headers string `gorm:"type:text;comment:自定义Headers JSON数组" json:"headers,omitempty"`
SkipTLSVerify bool `gorm:"default:false;comment:跳过TLS验证" json:"skip_tls_verify"`
DefaultIndex string `gorm:"type:varchar(128);comment:ES默认索引" json:"default_index,omitempty"`
IsDefault bool `gorm:"default:false;index;comment:是否默认" json:"is_default"`
@@ -32,9 +35,12 @@ type CreateLogDSReq struct {
Name string `json:"name" binding:"required"`
Type string `json:"type" binding:"required"`
URL string `json:"url" binding:"required"`
AuthType string `json:"auth_type"`
BasicAuth bool `json:"basic_auth"`
BasicAuthUser string `json:"basic_auth_user"`
BasicAuthPass string `json:"basic_auth_pass"`
Token string `json:"token"`
Headers string `json:"headers"`
SkipTLSVerify bool `json:"skip_tls_verify"`
DefaultIndex string `json:"default_index"`
IsDefault bool `json:"is_default"`
@@ -45,9 +51,12 @@ type UpdateLogDSReq struct {
Name *string `json:"name"`
Type *string `json:"type"`
URL *string `json:"url"`
AuthType *string `json:"auth_type"`
BasicAuth *bool `json:"basic_auth"`
BasicAuthUser *string `json:"basic_auth_user"`
BasicAuthPass *string `json:"basic_auth_pass"`
Token *string `json:"token"`
Headers *string `json:"headers"`
SkipTLSVerify *bool `json:"skip_tls_verify"`
DefaultIndex *string `json:"default_index"`
IsDefault *bool `json:"is_default"`
@@ -62,8 +71,11 @@ type TestLogDSReq struct {
DatasourceID uint `json:"datasource_id"`
Type string `json:"type"`
URL string `json:"url"`
AuthType string `json:"auth_type"`
BasicAuth bool `json:"basic_auth"`
BasicAuthUser string `json:"basic_auth_user"`
BasicAuthPass string `json:"basic_auth_pass"`
Token string `json:"token"`
Headers string `json:"headers"`
SkipTLSVerify bool `json:"skip_tls_verify"`
}