mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
alerting: fixed issue with included alerting error & no data reasons, fixes #8412
This commit is contained in:
@@ -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,25 +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.reason = "";
|
||||
|
||||
if (_.isArray(ah.data)) {
|
||||
ah.reason = "Conditions";
|
||||
ah.metrics = alertDef.joinEvalMatches(ah.data, ', ');
|
||||
} else if (_.isArray(ah.data.evalMatches)) {
|
||||
ah.metrics = alertDef.joinEvalMatches(ah.data.evalMatches, ', ');
|
||||
}
|
||||
|
||||
if (ah.data.error) {
|
||||
ah.metrics = "" + ah.data.error;
|
||||
ah.reason = "Error";
|
||||
}
|
||||
|
||||
if (ah.data.noData || ah.data.no_data) {
|
||||
ah.metrics = "";
|
||||
ah.reason = "No Data";
|
||||
}
|
||||
|
||||
ah.info = alertDef.getAlertAnnotationInfo(ah);
|
||||
return ah;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
</span> {{ah.time}}
|
||||
</div>
|
||||
<div class="card-item-sub-name">
|
||||
{{ah.metrics}}
|
||||
{{ah.info}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user