mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #1447 from prometheus/fabxc/alertfix
Make copying alerting state safer.
This commit is contained in:
commit
6adf77e411
|
@ -110,6 +110,10 @@ func (rule *AlertingRule) Name() string {
|
||||||
return rule.name
|
return rule.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *AlertingRule) equal(o *AlertingRule) bool {
|
||||||
|
return r.name == o.name && r.labels.Equal(o.labels)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *AlertingRule) sample(alert *Alert, ts model.Time, set bool) *model.Sample {
|
func (r *AlertingRule) sample(alert *Alert, ts model.Time, set bool) *model.Sample {
|
||||||
metric := model.Metric(r.labels.Clone())
|
metric := model.Metric(r.labels.Clone())
|
||||||
|
|
||||||
|
|
|
@ -212,8 +212,12 @@ func (g *Group) copyState(from *Group) {
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if far.Name() == ar.Name() {
|
// TODO(fabxc): forbid same alert definitions that are not unique by
|
||||||
ar.active = far.active
|
// at least on static label or alertname?
|
||||||
|
if far.equal(ar) {
|
||||||
|
for fp, a := range far.active {
|
||||||
|
ar.active[fp] = a
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue