41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package alert
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Alert struct {
|
|
ID string `json:"id" gorm:"type:uuid;primaryKey"`
|
|
PrimaryRuleID string `json:"primaryRuleId" gorm:"type:uuid;not null;index"`
|
|
CorrelationKey string `json:"-" gorm:"size:384;not null"`
|
|
Status string `json:"status" gorm:"size:24;not null;default:open;index"`
|
|
Severity string `json:"severity" gorm:"size:16;not null;index"`
|
|
Summary string `json:"summary" gorm:"size:256;not null"`
|
|
Location string `json:"location" gorm:"size:256;not null;index"`
|
|
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz;not null;index"`
|
|
UpdatedAt time.Time `json:"updatedAt" gorm:"type:timestamptz;not null"`
|
|
}
|
|
|
|
func (Alert) TableName() string { return "bell_alerts" }
|
|
|
|
type AlertEvent struct {
|
|
AlertID string `json:"alertId" gorm:"type:uuid;primaryKey"`
|
|
EventID string `json:"eventId" gorm:"type:uuid;primaryKey"`
|
|
LinkedAt time.Time `json:"linkedAt" gorm:"type:timestamptz;not null"`
|
|
}
|
|
|
|
func (AlertEvent) TableName() string { return "bell_alert_events" }
|
|
|
|
type RuleMatch struct {
|
|
EventID string `json:"eventId" gorm:"type:uuid;primaryKey"`
|
|
RuleID string `json:"ruleId" gorm:"type:uuid;primaryKey"`
|
|
AlertID string `json:"alertId" gorm:"type:uuid;not null;index"`
|
|
RuleVersion int `json:"ruleVersion" gorm:"not null"`
|
|
RuleSnapshot json.RawMessage `json:"ruleSnapshot" gorm:"type:jsonb;not null"`
|
|
Explanation string `json:"explanation" gorm:"size:512;not null"`
|
|
MatchedAt time.Time `json:"matchedAt" gorm:"type:timestamptz;not null"`
|
|
}
|
|
|
|
func (RuleMatch) TableName() string { return "bell_rule_matches" }
|