diff --git a/modules/grafana/client.go b/modules/grafana/client.go index 02e5c7d8..63a678c2 100644 --- a/modules/grafana/client.go +++ b/modules/grafana/client.go @@ -3,6 +3,7 @@ package grafana import ( "bytes" "encoding/json" + "errors" "fmt" "net/http" "sort" @@ -91,6 +92,17 @@ func (client *Client) Alerts() ([]Alert, error) { } defer func() { _ = res.Body.Close() }() + if res.StatusCode != 200 { + msg := struct { + Msg string `json:"message"` + }{} + err = utils.ParseJSON(&msg, res.Body) + if err != nil { + return nil, err + } + return nil, errors.New(msg.Msg) + } + var out []Alert err = utils.ParseJSON(&out, res.Body) if err != nil {