mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
feat(alerting): save execution error message to annotations
This commit is contained in:
parent
c624f3d470
commit
4619a05f43
@ -31,12 +31,15 @@ func (handler *DefaultResultHandler) Handle(ctx *EvalContext) {
|
||||
oldState := ctx.Rule.State
|
||||
|
||||
exeuctionError := ""
|
||||
annotationData := simplejson.New()
|
||||
if ctx.Error != nil {
|
||||
handler.log.Error("Alert Rule Result Error", "ruleId", ctx.Rule.Id, "error", ctx.Error)
|
||||
ctx.Rule.State = m.AlertStateExeuctionError
|
||||
exeuctionError = ctx.Error.Error()
|
||||
annotationData.Set("errorMessage", exeuctionError)
|
||||
} else if ctx.Firing {
|
||||
ctx.Rule.State = m.AlertStateType(ctx.Rule.Severity)
|
||||
annotationData = simplejson.NewFromAny(ctx.EvalMatches)
|
||||
} else {
|
||||
ctx.Rule.State = m.AlertStateOK
|
||||
}
|
||||
@ -66,7 +69,7 @@ func (handler *DefaultResultHandler) Handle(ctx *EvalContext) {
|
||||
NewState: string(ctx.Rule.State),
|
||||
PrevState: string(oldState),
|
||||
Timestamp: time.Now(),
|
||||
Data: simplejson.NewFromAny(ctx.EvalMatches),
|
||||
Data: annotationData,
|
||||
}
|
||||
|
||||
annotationRepo := annotations.GetRepository()
|
||||
|
@ -49,12 +49,12 @@ func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryC
|
||||
}
|
||||
|
||||
res, err := client.Do(req)
|
||||
defer res.Body.Close()
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
return result
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
|
Loading…
Reference in New Issue
Block a user