mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: No longer silence paused alerts during legacy migration (#71596)
* Alerting: No longer silence paused alerts during legacy migration Now that we migrate paused legacy alerts to paused UA alert rules, we no longer need to silence them.
This commit is contained in:
parent
061ccb13d8
commit
8c6cdf51fc
@ -154,4 +154,3 @@ longer supported.
|
||||
**Limitations**
|
||||
|
||||
1. Since `Hipchat` and `Sensu` notification channels are no longer supported, legacy alerts associated with these channels are not automatically migrated to Grafana Alerting. Assign the legacy alerts to a supported notification channel so that you continue to receive notifications for those alerts.
|
||||
Silences (expiring after one year) are created for all paused dashboard alerts.
|
||||
|
@ -152,10 +152,6 @@ func (m *migration) makeAlertRule(l log.Logger, cond condition, da dashAlert, fo
|
||||
n, v := getLabelForSilenceMatching(ar.UID)
|
||||
ar.Labels[n] = v
|
||||
|
||||
if err := m.addSilence(da, ar); err != nil {
|
||||
m.mg.Logger.Error("alert migration error: failed to create silence", "rule_name", ar.Title, "err", err)
|
||||
}
|
||||
|
||||
if err := m.addErrorSilence(da, ar); err != nil {
|
||||
m.mg.Logger.Error("alert migration error: failed to create silence for Error", "rule_name", ar.Title, "err", err)
|
||||
}
|
||||
|
@ -26,43 +26,6 @@ const (
|
||||
ErrorAlertName = "DatasourceError"
|
||||
)
|
||||
|
||||
func (m *migration) addSilence(da dashAlert, rule *alertRule) error {
|
||||
if da.State != "paused" {
|
||||
return nil
|
||||
}
|
||||
|
||||
uid, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
return errors.New("failed to create uuid for silence")
|
||||
}
|
||||
|
||||
n, v := getLabelForSilenceMatching(rule.UID)
|
||||
s := &pb.MeshSilence{
|
||||
Silence: &pb.Silence{
|
||||
Id: uid.String(),
|
||||
Matchers: []*pb.Matcher{
|
||||
{
|
||||
Type: pb.Matcher_EQUAL,
|
||||
Name: n,
|
||||
Pattern: v,
|
||||
},
|
||||
},
|
||||
StartsAt: time.Now(),
|
||||
EndsAt: time.Now().Add(365 * 20 * time.Hour), // 1 year.
|
||||
CreatedBy: "Grafana Migration",
|
||||
Comment: "Created during auto migration to unified alerting",
|
||||
},
|
||||
ExpiresAt: time.Now().Add(365 * 20 * time.Hour), // 1 year.
|
||||
}
|
||||
|
||||
_, ok := m.silences[da.OrgId]
|
||||
if !ok {
|
||||
m.silences[da.OrgId] = make([]*pb.MeshSilence, 0)
|
||||
}
|
||||
m.silences[da.OrgId] = append(m.silences[da.OrgId], s)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *migration) addErrorSilence(da dashAlert, rule *alertRule) error {
|
||||
if da.ParsedSettings.ExecutionErrorState != "keep_state" {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user