Commit d5481fa0 by Torkel Ödegaard

Merge branch 'master' into query_troubleshooting

parents fbc3e037 59f3cca1
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
## Bug fixes ## Bug fixes
* **Graphite**: Fixed issue with Toggle edit mode did in query editor [#8377](https://github.com/grafana/grafana/issues/8377) * **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) # 4.3.0-beta1 (2017-05-12)
......
...@@ -31,17 +31,15 @@ func (handler *DefaultResultHandler) Handle(evalContext *EvalContext) error { ...@@ -31,17 +31,15 @@ func (handler *DefaultResultHandler) Handle(evalContext *EvalContext) error {
executionError := "" executionError := ""
annotationData := simplejson.New() annotationData := simplejson.New()
if evalContext.Firing { if len(evalContext.EvalMatches) > 0 {
annotationData = simplejson.NewFromAny(evalContext.EvalMatches) annotationData.Set("evalMatches", simplejson.NewFromAny(evalContext.EvalMatches))
} }
if evalContext.Error != nil { if evalContext.Error != nil {
executionError = evalContext.Error.Error() executionError = evalContext.Error.Error()
annotationData.Set("errorMessage", executionError) annotationData.Set("error", executionError)
} } else if evalContext.NoDataFound {
annotationData.Set("noData", true)
if evalContext.NoDataFound {
annotationData.Set("no_data", true)
} }
countStateResult(evalContext.Rule.State) countStateResult(evalContext.Rule.State)
......
...@@ -131,6 +131,29 @@ function joinEvalMatches(matches, separator: string) { ...@@ -131,6 +131,29 @@ function joinEvalMatches(matches, separator: string) {
}, []).join(separator); }, []).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 { export default {
alertQueryDef: alertQueryDef, alertQueryDef: alertQueryDef,
getStateDisplayModel: getStateDisplayModel, getStateDisplayModel: getStateDisplayModel,
...@@ -141,6 +164,6 @@ export default { ...@@ -141,6 +164,6 @@ export default {
executionErrorModes: executionErrorModes, executionErrorModes: executionErrorModes,
reducerTypes: reducerTypes, reducerTypes: reducerTypes,
createReducerPart: createReducerPart, createReducerPart: createReducerPart,
joinEvalMatches: joinEvalMatches, getAlertAnnotationInfo: getAlertAnnotationInfo,
alertStateSortScore: alertStateSortScore, alertStateSortScore: alertStateSortScore,
}; };
...@@ -81,16 +81,7 @@ export class AlertTabCtrl { ...@@ -81,16 +81,7 @@ export class AlertTabCtrl {
this.alertHistory = _.map(res, ah => { this.alertHistory = _.map(res, ah => {
ah.time = moment(ah.time).format('MMM D, YYYY HH:mm:ss'); ah.time = moment(ah.time).format('MMM D, YYYY HH:mm:ss');
ah.stateModel = alertDef.getStateDisplayModel(ah.newState); ah.stateModel = alertDef.getStateDisplayModel(ah.newState);
ah.metrics = alertDef.joinEvalMatches(ah.data, ', '); ah.info = alertDef.getAlertAnnotationInfo(ah);
if (ah.data.errorMessage) {
ah.metrics = "Error: " + ah.data.errorMessage;
}
if (ah.data.no_data) {
ah.metrics = "(due to no data)";
}
return ah; return ah;
}); });
}); });
......
...@@ -148,16 +148,20 @@ ...@@ -148,16 +148,20 @@
<ol class="card-list" > <ol class="card-list" >
<li class="card-item-wrapper" ng-repeat="ah in ctrl.alertHistory"> <li class="card-item-wrapper" ng-repeat="ah in ctrl.alertHistory">
<div class="card-item card-item--alert"> <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-body">
<div class="card-item-details"> <div class="card-item-details">
<div class="card-item-sub-name"> <div class="card-item-sub-name">
<span class="alert-list-item-state {{ah.stateModel.stateClass}}"> <span class="alert-list-item-state {{ah.stateModel.stateClass}}">
<i class="{{ah.stateModel.iconClass}}"></i> <i class="{{ah.stateModel.iconClass}}"></i>
{{ah.stateModel.text}} {{ah.stateModel.text}}
</span> {{ah.metrics}} </span> {{ah.time}}
</div> </div>
<div class="card-item-sub-name"> <div class="card-item-sub-name">
{{ah.time}} {{ah.info}}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<span class="alert-list-item-state {{al.stateModel.stateClass}}"> <span class="alert-list-item-state {{al.stateModel.stateClass}}">
<i class="{{al.stateModel.iconClass}}"></i> <i class="{{al.stateModel.iconClass}}"></i>
{{al.stateModel.text}} {{al.stateModel.text}}
</span> {{al.metrics}} </span> {{al.info}}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -106,7 +106,7 @@ class AlertListPanel extends PanelCtrl { ...@@ -106,7 +106,7 @@ class AlertListPanel extends PanelCtrl {
this.alertHistory = _.map(res, al => { this.alertHistory = _.map(res, al => {
al.time = moment(al.time).format('MMM D, YYYY HH:mm:ss'); al.time = moment(al.time).format('MMM D, YYYY HH:mm:ss');
al.stateModel = alertDef.getStateDisplayModel(al.newState); al.stateModel = alertDef.getStateDisplayModel(al.newState);
al.metrics = alertDef.joinEvalMatches(al.data, ', '); al.info = alertDef.getAlertAnnotationInfo(al);
return al; return al;
}); });
}); });
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
display: block; display: block;
color: $text-color; color: $text-color;
margin: 0 0 1.5rem 1rem; 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