mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: New API endpoint GET /api/v1/ngalert (#55134)
* declare new endpoint /api/v1/ngalert * add authorization for new path * add request handler for the new path
This commit is contained in:
@@ -143,3 +143,22 @@ func (srv ConfigSrv) externalAlertmanagers(ctx context.Context, orgID int64) ([]
|
||||
}
|
||||
return alertmanagers, nil
|
||||
}
|
||||
|
||||
func (srv ConfigSrv) RouteGetAlertingStatus(c *models.ReqContext) response.Response {
|
||||
sendsAlertsTo := ngmodels.InternalAlertmanager
|
||||
|
||||
cfg, err := srv.store.GetAdminConfiguration(c.OrgID)
|
||||
if err != nil && !errors.Is(err, store.ErrNoAdminConfiguration) {
|
||||
msg := "failed to fetch configuration from the database"
|
||||
srv.log.Error(msg, "err", err)
|
||||
return ErrResp(http.StatusInternalServerError, err, msg)
|
||||
}
|
||||
if cfg != nil {
|
||||
sendsAlertsTo = cfg.SendAlertsTo
|
||||
}
|
||||
|
||||
resp := apimodels.AlertingStatus{
|
||||
AlertmanagersChoice: apimodels.AlertmanagersChoice(sendsAlertsTo.String()),
|
||||
}
|
||||
return response.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user