mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): add serie name to failed alert description
This commit is contained in:
@@ -122,5 +122,6 @@ type AlertResult struct {
|
||||
State string
|
||||
ActualValue float64
|
||||
Duration float64
|
||||
Description string
|
||||
Rule AlertRule
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package alerting
|
||||
import (
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
@@ -103,12 +102,7 @@ func (this *Scheduler) HandleResponses() {
|
||||
cmd := m.UpdateAlertStateCommand{
|
||||
AlertId: response.Id,
|
||||
NewState: response.State,
|
||||
}
|
||||
|
||||
if cmd.NewState != m.AlertStateOk {
|
||||
cmd.Info = fmt.Sprintf("Actual value: %1.2f", response.ActualValue)
|
||||
} else {
|
||||
cmd.Info = "Alert is OK!"
|
||||
Info: response.Description,
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&cmd); err != nil {
|
||||
|
||||
@@ -102,6 +102,7 @@ func (this *ExecutorImpl) ValidateRule(rule m.AlertRule, series m.TimeSeriesSlic
|
||||
State: m.AlertStateCritical,
|
||||
Id: rule.Id,
|
||||
ActualValue: aggValue,
|
||||
Description: fmt.Sprintf("Actual value: %1.2f for %s", aggValue, serie.Name),
|
||||
Rule: rule,
|
||||
}
|
||||
}
|
||||
@@ -110,11 +111,12 @@ func (this *ExecutorImpl) ValidateRule(rule m.AlertRule, series m.TimeSeriesSlic
|
||||
return &m.AlertResult{
|
||||
State: m.AlertStateWarn,
|
||||
Id: rule.Id,
|
||||
Description: fmt.Sprintf("Actual value: %1.2f for %s", aggValue, serie.Name),
|
||||
ActualValue: aggValue,
|
||||
Rule: rule,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &m.AlertResult{State: m.AlertStateOk, Id: rule.Id, Rule: rule}
|
||||
return &m.AlertResult{State: m.AlertStateOk, Id: rule.Id, Rule: rule, Description: "Alert is OK!"}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user