[v10.0.x] Alerting: No longer silence paused alerts during legacy migration (#71761)
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.
(cherry picked from commit 8c6cdf51fc)
Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
co-authored by
Matthew Jacobson
parent
1bce7bb76e
commit
f9a8e0a50d
@@ -156,4 +156,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
|
||||
|
||||
Reference in New Issue
Block a user