Просмотр исходного кода

feat(alerting): renames error_level to crit_level

bergquist 9 лет назад
Родитель
Сommit
ef92fd4ebc

+ 4 - 4
pkg/models/alerts.go

@@ -10,8 +10,8 @@ type Alert struct {
 	PanelId     int64
 	Query       string
 	QueryRefId  string
-	WarnLevel   int64
-	ErrorLevel  int64
+	WarnLevel   string
+	CritLevel   string
 	Interval    int64
 	Title       string
 	Description string
@@ -34,8 +34,8 @@ func (cmd *SaveDashboardCommand) GetAlertModels() *[]Alert {
 				PanelId:     panel.Get("id").MustInt64(),
 				Id:          alerting.Get("id").MustInt64(),
 				QueryRefId:  alerting.Get("query_ref").MustString(),
-				WarnLevel:   alerting.Get("warn_level").MustInt64(),
-				ErrorLevel:  alerting.Get("error_level").MustInt64(),
+				WarnLevel:   alerting.Get("warn_level").MustString(),
+				CritLevel:   alerting.Get("crit_level").MustString(),
 				Interval:    alerting.Get("interval").MustInt64(),
 				Title:       alerting.Get("title").MustString(),
 				Description: alerting.Get("description").MustString(),

+ 4 - 4
pkg/models/alerts_test.go

@@ -68,8 +68,8 @@ func TestAlertModel(t *testing.T) {
           "steppedLine": false,
           "alerting": {
 						"query_ref": "A",
-						"warn_level": 30,
-						"error_level": 50,
+						"warn_level": "> 30",
+						"crit_level": "> 50",
 						"title": "desktop visiter alerts",
 						"description": "Restart the webservers",
 						"query_range": "5m",
@@ -273,8 +273,8 @@ func TestAlertModel(t *testing.T) {
 				So(v.DashboardId, ShouldEqual, 1)
 				So(v.PanelId, ShouldNotEqual, 0)
 
-				So(v.WarnLevel, ShouldEqual, 30)
-				So(v.ErrorLevel, ShouldEqual, 50)
+				So(v.WarnLevel, ShouldEqual, "> 30")
+				So(v.CritLevel, ShouldEqual, "> 50")
 
 				So(v.Aggregator, ShouldNotBeEmpty)
 				So(v.Query, ShouldNotBeEmpty)

+ 2 - 2
pkg/services/sqlstore/alerting_test.go

@@ -19,8 +19,8 @@ func TestAlertingDataAccess(t *testing.T) {
 					DashboardId: 1,
 					Query:       "Query",
 					QueryRefId:  "A",
-					WarnLevel:   30,
-					ErrorLevel:  50,
+					WarnLevel:   "> 30",
+					CritLevel:   "> 50",
 					Interval:    10,
 					Title:       "Alerting title",
 					Description: "Alerting description",

+ 2 - 2
pkg/services/sqlstore/migrations/alert_mig.go

@@ -13,8 +13,8 @@ func addAlertMigrations(mg *Migrator) {
 			{Name: "panel_id", Type: DB_BigInt, Nullable: false},
 			{Name: "query", Type: DB_Text, Nullable: false},
 			{Name: "query_ref_id", Type: DB_NVarchar, Length: 255, Nullable: false},
-			{Name: "warn_level", Type: DB_BigInt, Nullable: false},
-			{Name: "error_level", Type: DB_BigInt, Nullable: false},
+			{Name: "warn_level", Type: DB_NVarchar, Length: 255, Nullable: false},
+			{Name: "crit_level", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "interval", Type: DB_BigInt, Nullable: false},
 			{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},