mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-18 03:27:04 +00:00
calculate stale resolve time on initial insert
This commit is contained in:
parent
2533f63a2d
commit
1ffa8b78d3
@ -96,21 +96,8 @@ func (d *Dispatcher) Run() {
|
|||||||
d.processAlert(alert, m)
|
d.processAlert(alert, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !alert.Resolved() {
|
if alert.ResolvedAt.IsZero() {
|
||||||
a := *alert
|
alert.ResolvedAt = alert.CreatedAt.Add(ResolveTimeout)
|
||||||
a.ResolvedAt = alert.CreatedAt.Add(ResolveTimeout)
|
|
||||||
|
|
||||||
// After the constant timeout update the alert to be resolved.
|
|
||||||
go func(a Alert) {
|
|
||||||
now := time.Now()
|
|
||||||
|
|
||||||
if a.ResolvedAt.After(now) {
|
|
||||||
time.Sleep(a.ResolvedAt.Sub(now))
|
|
||||||
}
|
|
||||||
if err := d.state.Alert().Add(&a); err != nil {
|
|
||||||
log.Errorf("alert auto-resolve failed: %s", err)
|
|
||||||
}
|
|
||||||
}(a)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +154,7 @@ func (a *Alert) Fingerprint() model.Fingerprint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Alert) String() string {
|
func (a *Alert) String() string {
|
||||||
s := fmt.Sprintf("%s[%x]", a.Name(), a.Fingerprint())
|
s := fmt.Sprintf("%s[%s]", a.Name(), a.Fingerprint())
|
||||||
if a.Resolved() {
|
if a.Resolved() {
|
||||||
return s + "[resolved]"
|
return s + "[resolved]"
|
||||||
}
|
}
|
||||||
@ -175,7 +162,10 @@ func (a *Alert) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Alert) Resolved() bool {
|
func (a *Alert) Resolved() bool {
|
||||||
return a.ResolvedAt.After(a.CreatedAt)
|
if a.ResolvedAt.IsZero() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return !a.ResolvedAt.After(time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggrGroup aggregates alerts into groups based on
|
// aggrGroup aggregates alerts into groups based on
|
||||||
|
Loading…
Reference in New Issue
Block a user