diff --git a/pkg/api/api.go b/pkg/api/api.go index fa3717e165e..5d169354a80 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -239,14 +239,15 @@ func Register(r *macaron.Macaron) { r.Get("/metrics/test", GetTestMetrics) r.Group("/alerts", func() { - r.Get("/events/:alertId", wrap(GetAlertState)) - r.Put("/events/:alertId", bind(m.UpdateAlertStateCommand{}), wrap(PutAlertState)) - r.Get("/changes", wrap(GetAlertChanges)) - r.Get("/", wrap(GetAlerts)) + r.Get("/:alertId/states", wrap(GetAlertState)) + r.Put("/:alertId/state", bind(m.UpdateAlertStateCommand{}), wrap(PutAlertState)) r.Get("/:alertId", ValidateOrgAlert, wrap(GetAlert)) + r.Get("/", wrap(GetAlerts)) r.Delete("/:alertId", ValidateOrgAlert, wrap(DelAlert)) }) + r.Get("/alert-changes", wrap(GetAlertChanges)) + r.Get("/alerts-dashboard/:dashboardId", wrap(GetAlertsForDashboard)) r.Get("/alerts-dashboard/:dashboardId/:panelId", wrap(GetAlertsForPanel)) diff --git a/pkg/services/sqlstore/alert_rule_changes_test.go b/pkg/services/sqlstore/alert_rule_changes_test.go index 70034505d43..dce2e3b262d 100644 --- a/pkg/services/sqlstore/alert_rule_changes_test.go +++ b/pkg/services/sqlstore/alert_rule_changes_test.go @@ -82,6 +82,7 @@ func TestAlertRuleChangesDataAccess(t *testing.T) { SaveAlertChange("UPDATED", items[0], sess) SaveAlertChange("UPDATED", items[0], sess) SaveAlertChange("UPDATED", items[0], sess) + sess.Commit() Convey("query for max one change", func() { query := &m.GetAlertChangesQuery{OrgId: FakeOrgId, Limit: 1} diff --git a/public/app/features/alerts/alert_log_ctrl.ts b/public/app/features/alerts/alert_log_ctrl.ts index 61f25d3d24d..48bb2f74192 100644 --- a/public/app/features/alerts/alert_log_ctrl.ts +++ b/public/app/features/alerts/alert_log_ctrl.ts @@ -22,7 +22,7 @@ export class AlertLogCtrl { } loadAlertLogs() { - this.backendSrv.get('/api/alerts/events/' + this.alertId).then(result => { + this.backendSrv.get(`/api/alerts/${this.alertId}/states/`).then(result => { this.alertLogs = _.map(result, log => { log.iconCss = alertDef.getCssForState(log.newState); log.humanTime = moment(log.created).format("YYYY-MM-DD HH:mm:ss"); @@ -30,7 +30,7 @@ export class AlertLogCtrl { }); }); - this.backendSrv.get('/api/alerts/' + this.alertId).then(result => { + this.backendSrv.get(`api/alerts/${this.alertId}`).then(result => { this.alert = result; }); } diff --git a/public/app/plugins/panel/graph/alert_tab_ctrl.ts b/public/app/plugins/panel/graph/alert_tab_ctrl.ts index 778962d438c..4aca42c56a7 100644 --- a/public/app/plugins/panel/graph/alert_tab_ctrl.ts +++ b/public/app/plugins/panel/graph/alert_tab_ctrl.ts @@ -9,6 +9,8 @@ export class AlertTabCtrl { panelCtrl: any; alerting: any; metricTargets = [{ refId: '- select query -' } ]; + operators = ['>', '<', '<=', '>=']; + aggregators = ['avg', 'sum', 'min', 'max', 'median']; /** @ngInject */ constructor($scope, private $timeout) { diff --git a/public/app/plugins/panel/graph/partials/tab_alerting.html b/public/app/plugins/panel/graph/partials/tab_alerting.html index e0f160efbb3..0f78b5558fb 100644 --- a/public/app/plugins/panel/graph/partials/tab_alerting.html +++ b/public/app/plugins/panel/graph/partials/tab_alerting.html @@ -17,7 +17,7 @@ Warn level
- +
@@ -27,7 +27,7 @@ Critical level
- +
@@ -40,7 +40,7 @@
+ ng-options="oper as oper for oper in alertTab.aggregators">