mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix potential panic in Alertmanager when starting up (#36562)
* Alerting: Fix potential panic in Alertmanager when starting up Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com> * Fix reviews Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
var (
|
||||
ErrGetAlertsInternal = fmt.Errorf("unable to retrieve alerts(s) due to an internal error")
|
||||
ErrGetAlertsUnavailable = fmt.Errorf("unable to retrieve alerts(s) as alertmanager is not initialised yet")
|
||||
ErrGetAlertsBadPayload = fmt.Errorf("unable to retrieve alerts")
|
||||
ErrGetAlertGroupsBadPayload = fmt.Errorf("unable to retrieve alerts groups")
|
||||
)
|
||||
@@ -27,6 +28,10 @@ func (am *Alertmanager) GetAlerts(active, silenced, inhibited bool, filter []str
|
||||
res = apimodels.GettableAlerts{}
|
||||
)
|
||||
|
||||
if !am.initialised {
|
||||
return res, ErrGetAlertsUnavailable
|
||||
}
|
||||
|
||||
matchers, err := parseFilter(filter)
|
||||
if err != nil {
|
||||
am.logger.Error("failed to parse matchers", "err", err)
|
||||
|
||||
Reference in New Issue
Block a user