mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AlertingNG: remove warn/crit from eval prototype (#28334)
and misc cleanup
This commit is contained in:
@@ -355,7 +355,7 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
if hs.Cfg.IsNgAlertEnabled() {
|
||||
apiRoute.Group("/alert-definitions", func(alertDefinitions routing.RouteRegister) {
|
||||
alertDefinitions.Get("/eval/:dashboardID/:panelID/:refID", reqEditorRole, Wrap(hs.AlertDefinitionEval))
|
||||
alertDefinitions.Post("/eval", reqEditorRole, bind(dtos.EvalAlertConditionsCommand{}), Wrap(hs.ConditionsEval))
|
||||
alertDefinitions.Post("/eval", reqEditorRole, bind(dtos.EvalAlertConditionCommand{}), Wrap(hs.ConditionEval))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
eval "github.com/grafana/grafana/pkg/services/ngalert"
|
||||
)
|
||||
|
||||
type EvalAlertConditionsCommand struct {
|
||||
Conditions eval.Conditions `json:"conditions"`
|
||||
Now time.Time `json:"now"`
|
||||
type EvalAlertConditionCommand struct {
|
||||
Condition eval.Condition `json:"condition"`
|
||||
Now time.Time `json:"now"`
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// POST /api/alert-definitions/eval
|
||||
func (hs *HTTPServer) ConditionsEval(c *models.ReqContext, dto dtos.EvalAlertConditionsCommand) Response {
|
||||
func (hs *HTTPServer) ConditionEval(c *models.ReqContext, dto dtos.EvalAlertConditionCommand) Response {
|
||||
alertCtx, cancelFn := context.WithTimeout(context.Background(), setting.AlertingEvaluationTimeout)
|
||||
defer cancelFn()
|
||||
|
||||
@@ -29,7 +29,7 @@ func (hs *HTTPServer) ConditionsEval(c *models.ReqContext, dto dtos.EvalAlertCon
|
||||
toStr = "now"
|
||||
}
|
||||
|
||||
execResult, err := dto.Conditions.Execute(alertExecCtx, fromStr, toStr)
|
||||
execResult, err := dto.Condition.Execute(alertExecCtx, fromStr, toStr)
|
||||
if err != nil {
|
||||
return Error(400, "Failed to execute conditions", err)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (hs *HTTPServer) AlertDefinitionEval(c *models.ReqContext) Response {
|
||||
toStr = "now"
|
||||
}
|
||||
|
||||
conditions, err := hs.AlertNG.LoadAlertConditions(dashboardID, panelID, conditionRefID, c.SignedInUser, c.SkipCache)
|
||||
conditions, err := hs.AlertNG.LoadAlertCondition(dashboardID, panelID, conditionRefID, c.SignedInUser, c.SkipCache)
|
||||
if err != nil {
|
||||
return Error(400, "Failed to load conditions", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user