Browse Source

feat(alerting): restored alert history

Torkel Ödegaard 9 years ago
parent
commit
3af891d023

+ 4 - 2
pkg/services/sqlstore/annotation.go

@@ -53,8 +53,10 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
 		params = append(params, query.PanelId)
 		params = append(params, query.PanelId)
 	}
 	}
 
 
-	sql.WriteString(` AND epoch BETWEEN ? AND ?`)
-	params = append(params, query.From, query.To)
+	if query.From > 0 && query.To > 0 {
+		sql.WriteString(` AND epoch BETWEEN ? AND ?`)
+		params = append(params, query.From, query.To)
+	}
 
 
 	if query.Type != "" {
 	if query.Type != "" {
 		sql.WriteString(` AND type = ?`)
 		sql.WriteString(` AND type = ?`)

+ 1 - 1
public/app/features/alerting/alert_tab_ctrl.ts

@@ -86,7 +86,7 @@ export class AlertTabCtrl {
   }
   }
 
 
   getAlertHistory() {
   getAlertHistory() {
-    this.backendSrv.get(`/api/alert-history?dashboardId=${this.panelCtrl.dashboard.id}&panelId=${this.panel.id}&limit=50`).then(res => {
+    this.backendSrv.get(`/api/annotations?dashboardId=${this.panelCtrl.dashboard.id}&panelId=${this.panel.id}&limit=50`).then(res => {
       this.alertHistory = _.map(res, ah => {
       this.alertHistory = _.map(res, ah => {
         ah.time = moment(ah.timestamp).format('MMM D, YYYY HH:mm:ss');
         ah.time = moment(ah.timestamp).format('MMM D, YYYY HH:mm:ss');
         ah.stateModel = alertDef.getStateDisplayModel(ah.newState);
         ah.stateModel = alertDef.getStateDisplayModel(ah.newState);

+ 3 - 4
public/app/features/alerting/partials/alert_tab.html

@@ -27,11 +27,10 @@
 			<div class="gf-form-group">
 			<div class="gf-form-group">
 				<h5 class="section-heading">Alert Config</h5>
 				<h5 class="section-heading">Alert Config</h5>
 				<div class="gf-form">
 				<div class="gf-form">
-					<span class="gf-form-label width-8">Name</span>
-					<input type="text" class="gf-form-input width-25" ng-model="ctrl.alert.name">
-					<span class="gf-form-label width-8">Evaluate every</span>
+					<span class="gf-form-label width-6">Name</span>
+					<input type="text" class="gf-form-input width-20" ng-model="ctrl.alert.name">
+					<span class="gf-form-label">Evaluate every</span>
 					<input class="gf-form-input max-width-5" type="text" ng-model="ctrl.alert.frequency"></input>
 					<input class="gf-form-input max-width-5" type="text" ng-model="ctrl.alert.frequency"></input>
-					</div>
 				</div>
 				</div>
 			</div>
 			</div>