Browse Source

feat(alerting): add aggregator field

bergquist 9 years ago
parent
commit
769016783f
2 changed files with 26 additions and 23 deletions
  1. 24 22
      pkg/models/alerts.go
  2. 2 1
      pkg/services/sqlstore/migrations/alert_mig.go

+ 24 - 22
pkg/models/alerts.go

@@ -5,17 +5,18 @@ import (
 )
 )
 
 
 type Alert struct {
 type Alert struct {
-	Id            int64
-	DashboardId   int64
-	PanelId       int64
-	Query         string
-	QueryRefId    string
-	WarnLevel     int64
-	ErrorLevel    int64
-	CheckInterval string
-	Title         string
-	Description   string
-	QueryRange    string
+	Id          int64
+	DashboardId int64
+	PanelId     int64
+	Query       string
+	QueryRefId  string
+	WarnLevel   int64
+	ErrorLevel  int64
+	Interval    string
+	Title       string
+	Description string
+	QueryRange  string
+	Aggregator  string
 }
 }
 
 
 func (cmd *SaveDashboardCommand) GetAlertModels() *[]Alert {
 func (cmd *SaveDashboardCommand) GetAlertModels() *[]Alert {
@@ -24,17 +25,18 @@ func (cmd *SaveDashboardCommand) GetAlertModels() *[]Alert {
 	alerts := make([]Alert, 0)
 	alerts := make([]Alert, 0)
 
 
 	alerts = append(alerts, Alert{
 	alerts = append(alerts, Alert{
-		DashboardId:   dash.Id,
-		Id:            1,
-		PanelId:       1,
-		Query:         "",
-		QueryRefId:    "",
-		WarnLevel:     0,
-		ErrorLevel:    0,
-		CheckInterval: "5s",
-		Title:         dash.Title + " Alert",
-		Description:   dash.Title + " Description",
-		QueryRange:    "10m",
+		DashboardId: dash.Id,
+		Id:          1,
+		PanelId:     1,
+		Query:       "query",
+		QueryRefId:  "query_ref",
+		WarnLevel:   0,
+		ErrorLevel:  0,
+		Interval:    "5s",
+		Title:       dash.Title + " Alert",
+		Description: dash.Title + " Description",
+		QueryRange:  "10m",
+		Aggregator:  "avg",
 	})
 	})
 
 
 	return &alerts
 	return &alerts

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

@@ -15,10 +15,11 @@ func addAlertMigrations(mg *Migrator) {
 			{Name: "query_ref_id", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "query_ref_id", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "warn_level", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "warn_level", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "error_level", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "error_level", Type: DB_NVarchar, Length: 255, Nullable: false},
-			{Name: "check_interval", Type: DB_NVarchar, Length: 255, Nullable: false},
+			{Name: "interval", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "query_range", 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},
 		},
 		},
 	}
 	}