diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c5e9b08f5..55c4b60cf52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Bug fixes * **Graphite**: Fixed issue with Toggle edit mode did in query editor [#8377](https://github.com/grafana/grafana/issues/8377) +* **Alerting**: Fixed issue with state history not showing query execution errors [#8412](https://github.com/grafana/grafana/issues/8412) +* **Alerting**: Fixed issue with missing state history events/annotations when using sqlite3 database [#7992](https://github.com/grafana/grafana/issues/7992) +* **Sqlite**: Fixed with database table locked and using sqlite3 database [#7992](https://github.com/grafana/grafana/issues/7992) # 4.3.0-beta1 (2017-05-12) diff --git a/pkg/services/alerting/result_handler.go b/pkg/services/alerting/result_handler.go index 1298a5dda36..972fbd3a461 100644 --- a/pkg/services/alerting/result_handler.go +++ b/pkg/services/alerting/result_handler.go @@ -31,17 +31,15 @@ func (handler *DefaultResultHandler) Handle(evalContext *EvalContext) error { executionError := "" annotationData := simplejson.New() - if evalContext.Firing { - annotationData = simplejson.NewFromAny(evalContext.EvalMatches) + if len(evalContext.EvalMatches) > 0 { + annotationData.Set("evalMatches", simplejson.NewFromAny(evalContext.EvalMatches)) } if evalContext.Error != nil { executionError = evalContext.Error.Error() - annotationData.Set("errorMessage", executionError) - } - - if evalContext.NoDataFound { - annotationData.Set("no_data", true) + annotationData.Set("error", executionError) + } else if evalContext.NoDataFound { + annotationData.Set("noData", true) } countStateResult(evalContext.Rule.State) diff --git a/public/app/features/alerting/alert_def.ts b/public/app/features/alerting/alert_def.ts index c65a35878e7..dc5be8b41c4 100644 --- a/public/app/features/alerting/alert_def.ts +++ b/public/app/features/alerting/alert_def.ts @@ -131,6 +131,29 @@ function joinEvalMatches(matches, separator: string) { }, []).join(separator); } +function getAlertAnnotationInfo(ah) { + + // backward compatability, can be removed in grafana 5.x + // old way stored evalMatches in data property directly, + // new way stores it in evalMatches property on new data object + + if (_.isArray(ah.data)) { + return joinEvalMatches(ah.data, ', '); + } else if (_.isArray(ah.data.evalMatches)) { + return joinEvalMatches(ah.data.evalMatches, ', '); + } + + if (ah.data.error) { + return "Error: " + ah.data.error; + } + + if (ah.data.noData || ah.data.no_data) { + return "No Data"; + } + + return ""; +} + export default { alertQueryDef: alertQueryDef, getStateDisplayModel: getStateDisplayModel, @@ -141,6 +164,6 @@ export default { executionErrorModes: executionErrorModes, reducerTypes: reducerTypes, createReducerPart: createReducerPart, - joinEvalMatches: joinEvalMatches, + getAlertAnnotationInfo: getAlertAnnotationInfo, alertStateSortScore: alertStateSortScore, }; diff --git a/public/app/features/alerting/alert_tab_ctrl.ts b/public/app/features/alerting/alert_tab_ctrl.ts index b21e5363ad8..938b24ebc21 100644 --- a/public/app/features/alerting/alert_tab_ctrl.ts +++ b/public/app/features/alerting/alert_tab_ctrl.ts @@ -81,16 +81,7 @@ export class AlertTabCtrl { this.alertHistory = _.map(res, ah => { ah.time = moment(ah.time).format('MMM D, YYYY HH:mm:ss'); ah.stateModel = alertDef.getStateDisplayModel(ah.newState); - ah.metrics = alertDef.joinEvalMatches(ah.data, ', '); - - if (ah.data.errorMessage) { - ah.metrics = "Error: " + ah.data.errorMessage; - } - - if (ah.data.no_data) { - ah.metrics = "(due to no data)"; - } - + ah.info = alertDef.getAlertAnnotationInfo(ah); return ah; }); }); diff --git a/public/app/features/alerting/partials/alert_tab.html b/public/app/features/alerting/partials/alert_tab.html index 4c63c4507fc..2e7956d4a6e 100644 --- a/public/app/features/alerting/partials/alert_tab.html +++ b/public/app/features/alerting/partials/alert_tab.html @@ -148,16 +148,20 @@
  1. +
    +
    +
    +
    - {{ah.stateModel.text}} - {{ah.metrics}} + {{ah.stateModel.text}} + {{ah.time}}
    - {{ah.time}} + {{ah.info}}
    diff --git a/public/app/plugins/panel/alertlist/module.html b/public/app/plugins/panel/alertlist/module.html index 2940e2ae33e..2c0cb00d2ef 100644 --- a/public/app/plugins/panel/alertlist/module.html +++ b/public/app/plugins/panel/alertlist/module.html @@ -40,7 +40,7 @@ {{al.stateModel.text}} - {{al.metrics}} + {{al.info}}
    diff --git a/public/app/plugins/panel/alertlist/module.ts b/public/app/plugins/panel/alertlist/module.ts index 3795e1c8197..e120ed05b6d 100644 --- a/public/app/plugins/panel/alertlist/module.ts +++ b/public/app/plugins/panel/alertlist/module.ts @@ -106,7 +106,7 @@ class AlertListPanel extends PanelCtrl { this.alertHistory = _.map(res, al => { al.time = moment(al.time).format('MMM D, YYYY HH:mm:ss'); al.stateModel = alertDef.getStateDisplayModel(al.newState); - al.metrics = alertDef.joinEvalMatches(al.data, ', '); + al.info = alertDef.getAlertAnnotationInfo(al); return al; }); }); diff --git a/public/sass/components/edit_sidemenu.scss b/public/sass/components/edit_sidemenu.scss index d7844ab6f36..5da2f6a21ce 100644 --- a/public/sass/components/edit_sidemenu.scss +++ b/public/sass/components/edit_sidemenu.scss @@ -26,6 +26,7 @@ display: block; color: $text-color; margin: 0 0 1.5rem 1rem; + white-space: nowrap; } }