diff --git a/pkg/models/alert_state.go b/pkg/models/alert_state.go index 5dbfb2ee7cd..679da91f22f 100644 --- a/pkg/models/alert_state.go +++ b/pkg/models/alert_state.go @@ -11,7 +11,7 @@ type AlertState struct { Id int64 `json:"-"` OrgId int64 `json:"-"` AlertId int64 `json:"alertId"` - NewState string `json:"newState"` + State string `json:"state"` Created time.Time `json:"created"` Info string `json:"info"` TriggeredAlerts *simplejson.Json `json:"triggeredAlerts"` @@ -19,7 +19,7 @@ type AlertState struct { func (this *UpdateAlertStateCommand) IsValidState() bool { for _, v := range alertstates.ValidStates { - if this.NewState == v { + if this.State == v { return true } } @@ -31,7 +31,7 @@ func (this *UpdateAlertStateCommand) IsValidState() bool { type UpdateAlertStateCommand struct { AlertId int64 `json:"alertId" binding:"Required"` OrgId int64 `json:"orgId" binding:"Required"` - NewState string `json:"newState" binding:"Required"` + State string `json:"state" binding:"Required"` Info string `json:"info"` TriggeredAlerts *simplejson.Json `json:"triggeredAlerts"` diff --git a/pkg/services/alerting/result_handler.go b/pkg/services/alerting/result_handler.go index d3af23b1416..45cb1bde1a6 100644 --- a/pkg/services/alerting/result_handler.go +++ b/pkg/services/alerting/result_handler.go @@ -29,7 +29,7 @@ func (handler *ResultHandlerImpl) Handle(result *AlertResult) { if handler.shouldUpdateState(result) { cmd := &m.UpdateAlertStateCommand{ AlertId: result.AlertJob.Rule.Id, - NewState: result.State, + State: result.State, Info: result.Description, OrgId: result.AlertJob.Rule.OrgId, TriggeredAlerts: simplejson.NewFromAny(result.TriggeredAlerts), @@ -62,7 +62,7 @@ func (handler *ResultHandlerImpl) shouldUpdateState(result *AlertResult) bool { lastExecution := query.Result.Created asdf := result.StartTime.Add(time.Minute * -15) olderThen15Min := lastExecution.Before(asdf) - changedState := query.Result.NewState != result.State + changedState := query.Result.State != result.State return changedState || olderThen15Min } diff --git a/pkg/services/sqlstore/alert_state.go b/pkg/services/sqlstore/alert_state.go index 6eb51cf29cf..d335f7402a7 100644 --- a/pkg/services/sqlstore/alert_state.go +++ b/pkg/services/sqlstore/alert_state.go @@ -47,13 +47,13 @@ func SetNewAlertState(cmd *m.UpdateAlertStateCommand) error { return fmt.Errorf("Could not find alert") } - alert.State = cmd.NewState + alert.State = cmd.State sess.Id(alert.Id).Update(&alert) alertState := m.AlertState{ AlertId: cmd.AlertId, OrgId: cmd.OrgId, - NewState: cmd.NewState, + State: cmd.State, Info: cmd.Info, Created: time.Now(), TriggeredAlerts: cmd.TriggeredAlerts,