Files
dushixiang 6c8d2f13d3 feat: 告警规则实体化与服务监控按标签选探针
- 告警规则:独立实体(alert_rules 表),按优先级命中第一条生效;支持三种主机目标(全部/按主机/按标签)、7 类阈值、事件通知开关、IP 打码、推送渠道选择;未命中规则的主机不产生告警;列表支持外置启停
- 服务监控:新增按标签选择探针,与指定探针取并集,均为空时全部探针执行
- 公网 IP 采集:范围支持全部探针/按探针/按标签,兼容历史 custom 取值
- 告警历史:新增规则归属列;评估链路(指标/证书/服务下线/探针离线/到期提醒/事件通知)全部按主机命中规则驱动
- 设置页:左侧菜单改为浅色卡片容器并优化对比度,通知渠道移至公网 IP 采集之后;主菜单宽度调整为 240px
2026-08-23 19:53:35 +08:00

32 lines
2.6 KiB
Go

package models
import (
"github.com/pika-monitor/pika/internal/protocol"
"gorm.io/datatypes"
)
// MonitorTask 描述一个服务监控任务
type MonitorTask struct {
ID string `gorm:"primaryKey" json:"id"` // 任务 ID
Name string `gorm:"uniqueIndex" json:"name"` // 任务名称
Type string `gorm:"index" json:"type"` // 监控类型 http/tcp
Target string `json:"target"` // 目标地址
Description string `json:"description"` // 描述信息
Enabled bool `json:"enabled"` // 是否启用
ShowTargetPublic bool `json:"showTargetPublic"` // 在公开页面是否显示目标地址
Visibility string `gorm:"default:public" json:"visibility"` // 可见性: public-匿名可见, private-登录可见
Interval int `json:"interval"` // 检测频率(秒),默认 60
AgentIds datatypes.JSONSlice[string] `json:"agentIds"` // 指定的探针 ID 列表(JSON 数组)
AgentNames []string `gorm:"-" json:"agentNames"` // 指定的探针名称列表
Tags datatypes.JSONSlice[string] `json:"tags"` // 标签列表(拥有这些标签的探针都会执行此监控)
HTTPConfig datatypes.JSONType[protocol.HTTPMonitorConfig] `json:"httpConfig"` // HTTP 监控配置
TCPConfig datatypes.JSONType[protocol.TCPMonitorConfig] `json:"tcpConfig"` // TCP 监控配置
ICMPConfig datatypes.JSONType[protocol.ICMPMonitorConfig] `json:"icmpConfig"` // ICMP 监控配置
CreatedAt int64 `gorm:"autoCreateTime:milli" json:"createdAt"` // 创建时间
UpdatedAt int64 `gorm:"autoUpdateTime:milli" json:"updatedAt"` // 更新时间
}
func (MonitorTask) TableName() string {
return "monitor_tasks"
}