feat(alerting): add datasource name field

This commit is contained in:
bergquist
2016-04-27 09:06:19 +02:00
parent 973db1ac38
commit 7041169ffb
5 changed files with 210 additions and 118 deletions

View File

@@ -68,6 +68,7 @@ func alertIsDifferent(rule1, rule2 m.AlertRule) bool {
result = result || rule1.Title != rule2.Title
result = result || rule1.Description != rule2.Description
result = result || rule1.QueryRange != rule2.QueryRange
result = result || rule1.DatasourceName != rule2.DatasourceName
return result
}

View File

@@ -16,18 +16,19 @@ func TestAlertingDataAccess(t *testing.T) {
items := []m.AlertRule{
{
PanelId: 1,
DashboardId: testDash.Id,
OrgId: testDash.OrgId,
Query: "Query",
QueryRefId: "A",
WarnLevel: "> 30",
CritLevel: "> 50",
Interval: "10",
Title: "Alerting title",
Description: "Alerting description",
QueryRange: "5m",
Aggregator: "avg",
PanelId: 1,
DashboardId: testDash.Id,
OrgId: testDash.OrgId,
Query: "Query",
QueryRefId: "A",
WarnLevel: "> 30",
CritLevel: "> 50",
Interval: "10",
Title: "Alerting title",
Description: "Alerting description",
QueryRange: "5m",
Aggregator: "avg",
DatasourceName: "graphite",
},
}
@@ -62,6 +63,7 @@ func TestAlertingDataAccess(t *testing.T) {
So(alert.Description, ShouldEqual, "Alerting description")
So(alert.QueryRange, ShouldEqual, "5m")
So(alert.Aggregator, ShouldEqual, "avg")
So(alert.DatasourceName, ShouldEqual, "graphite")
})
Convey("Alerts with same dashboard id and panel id should update", func() {

View File

@@ -19,6 +19,7 @@ func addAlertMigrations(mg *Migrator) {
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "query_range", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "aggregator", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "datasource_name", Type: DB_NVarchar, Length: 255, Nullable: false},
},
}