Commit d5481fa0 by Torkel Ödegaard

Merge branch 'master' into query_troubleshooting

parents fbc3e037 59f3cca1
......@@ -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)
......
......@@ -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)
......
......@@ -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,
};
......@@ -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;
});
});
......
......@@ -148,16 +148,20 @@
<ol class="card-list" >
<li class="card-item-wrapper" ng-repeat="ah in ctrl.alertHistory">
<div class="card-item card-item--alert">
<div class="card-item-header">
<div class="card-item-type">
</div>
</div>
<div class="card-item-body">
<div class="card-item-details">
<div class="card-item-sub-name">
<span class="alert-list-item-state {{ah.stateModel.stateClass}}">
<i class="{{ah.stateModel.iconClass}}"></i>
{{ah.stateModel.text}}
</span> {{ah.metrics}}
</span> {{ah.time}}
</div>
<div class="card-item-sub-name">
{{ah.time}}
{{ah.info}}
</div>
</div>
</div>
......
......@@ -40,7 +40,7 @@
<span class="alert-list-item-state {{al.stateModel.stateClass}}">
<i class="{{al.stateModel.iconClass}}"></i>
{{al.stateModel.text}}
</span> {{al.metrics}}
</span> {{al.info}}
</div>
</div>
</div>
......
......@@ -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;
});
});
......
......@@ -26,6 +26,7 @@
display: block;
color: $text-color;
margin: 0 0 1.5rem 1rem;
white-space: nowrap;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment