diff --git a/alertmanager/models.go b/alertmanager/models.go index 546c639bf..4455a86c6 100644 --- a/alertmanager/models.go +++ b/alertmanager/models.go @@ -254,13 +254,11 @@ func (am *Alertmanager) SilenceByID(id string) (models.Silence, error) { am.lock.RLock() defer am.lock.RUnlock() - for k, v := range am.silences { - if k == id { - return models.Silence(v), nil - } + s, found := am.silences[id] + if !found { + return models.Silence{}, fmt.Errorf("Silence '%s' not found", id) } - - return models.Silence{}, fmt.Errorf("Silence '%s' not found", id) + return s, nil } // Colors returns a copy of all color maps