Check expiry in alert
This commit is contained in:
parent
d21860eee7
commit
618ebd23f4
|
@ -399,7 +399,11 @@ func (c *Cluster) Alerts() map[string]api.Alert {
|
|||
c.alertsMux.Lock()
|
||||
defer c.alertsMux.Unlock()
|
||||
for i, alert := range c.alerts {
|
||||
alerts[i] = alert
|
||||
if time.Now().Before(time.Unix(0, alert.Expiry)) {
|
||||
alerts[i] = alert
|
||||
} else {
|
||||
delete(c.alerts, i)
|
||||
}
|
||||
}
|
||||
|
||||
return alerts
|
||||
|
|
|
@ -132,6 +132,7 @@ func (mc *Checker) alert(pid peer.ID, metricName string) error {
|
|||
alrt := &api.Alert{
|
||||
Peer: pid,
|
||||
MetricName: metricName,
|
||||
Expiry: time.Now().Add(30 * time.Second).UnixNano(),
|
||||
}
|
||||
select {
|
||||
case mc.alertCh <- alrt:
|
||||
|
|
Loading…
Reference in New Issue
Block a user