Alerting: scheduler to use short version of model for alert rule (#48916)
* scheduler to use a short version of alert rule model
This commit is contained in:
@@ -113,6 +113,13 @@ type AlertRule struct {
|
||||
Labels map[string]string
|
||||
}
|
||||
|
||||
type SchedulableAlertRule struct {
|
||||
UID string `xorm:"uid"`
|
||||
OrgID int64 `xorm:"org_id"`
|
||||
IntervalSeconds int64
|
||||
Version int64
|
||||
}
|
||||
|
||||
type LabelOption func(map[string]string)
|
||||
|
||||
func WithoutInternalLabels() LabelOption {
|
||||
@@ -169,6 +176,11 @@ func (alertRule *AlertRule) GetKey() AlertRuleKey {
|
||||
return AlertRuleKey{OrgID: alertRule.OrgID, UID: alertRule.UID}
|
||||
}
|
||||
|
||||
// GetKey returns the alert definitions identifier
|
||||
func (alertRule *SchedulableAlertRule) GetKey() AlertRuleKey {
|
||||
return AlertRuleKey{OrgID: alertRule.OrgID, UID: alertRule.UID}
|
||||
}
|
||||
|
||||
// PreSave sets default values and loads the updated model for each alert query.
|
||||
func (alertRule *AlertRule) PreSave(timeNow func() time.Time) error {
|
||||
for i, q := range alertRule.Data {
|
||||
@@ -242,6 +254,12 @@ type ListAlertRulesQuery struct {
|
||||
Result []*AlertRule
|
||||
}
|
||||
|
||||
type GetAlertRulesForSchedulingQuery struct {
|
||||
ExcludeOrgIDs []int64
|
||||
|
||||
Result []*SchedulableAlertRule
|
||||
}
|
||||
|
||||
// ListNamespaceAlertRulesQuery is the query for listing namespace alert rules
|
||||
type ListNamespaceAlertRulesQuery struct {
|
||||
OrgID int64
|
||||
|
||||
Reference in New Issue
Block a user