Parcourir la source

tech(alerting): change interval -> frequency

bergquist il y a 9 ans
Parent
commit
077be210da

+ 1 - 1
pkg/api/alerting.go

@@ -68,7 +68,7 @@ func GetAlerts(c *middleware.Context) Response {
 			QueryRefId:  alert.QueryRefId,
 			WarnLevel:   alert.WarnLevel,
 			CritLevel:   alert.CritLevel,
-			Interval:    alert.Interval,
+			Frequency:   alert.Frequency,
 			Title:       alert.Title,
 			Description: alert.Description,
 			QueryRange:  alert.QueryRange,

+ 1 - 1
pkg/api/dtos/alerting.go

@@ -10,7 +10,7 @@ type AlertRuleDTO struct {
 	CritLevel    int64  `json:"critLevel"`
 	WarnOperator string `json:"warnOperator"`
 	CritOperator string `json:"critOperator"`
-	Interval     string `json:"interval"`
+	Frequency    int64  `json:"frequency"`
 	Title        string `json:"title"`
 	Description  string `json:"description"`
 	QueryRange   int    `json:"queryRange"`

+ 0 - 1
pkg/models/alerts.go

@@ -16,7 +16,6 @@ type AlertRule struct {
 	CritLevel    int64  `json:"critLevel"`
 	WarnOperator string `json:"warnOperator"`
 	CritOperator string `json:"critOperator"`
-	Interval     string `json:"interval"`
 	Frequency    int64  `json:"frequency"`
 	Title        string `json:"title"`
 	Description  string `json:"description"`

+ 0 - 1
pkg/services/alerting/alert_rule_reader.go

@@ -21,7 +21,6 @@ func (this AlertRuleReader) Fetch() []m.AlertRule {
 			Id:           1,
 			OrgId:        1,
 			Title:        "alert rule 1",
-			Interval:     "10s",
 			Frequency:    3,
 			DatasourceId: 1,
 			WarnOperator: "<",

+ 1 - 1
pkg/services/alerting/dashboard_parser.go

@@ -26,7 +26,7 @@ func ParseAlertsFromDashboard(cmd *m.SaveDashboardCommand) []m.AlertRule {
 				CritLevel:    alerting.Get("critLevel").MustInt64(),
 				WarnOperator: alerting.Get("warnOperator").MustString(),
 				CritOperator: alerting.Get("critOperator").MustString(),
-				Interval:     alerting.Get("interval").MustString(),
+				Frequency:    alerting.Get("interval").MustInt64(),
 				Title:        alerting.Get("title").MustString(),
 				Description:  alerting.Get("description").MustString(),
 				QueryRange:   alerting.Get("queryRange").MustInt(),

+ 1 - 1
pkg/services/sqlstore/alert_rule.go

@@ -112,7 +112,7 @@ func alertIsDifferent(rule1, rule2 m.AlertRule) bool {
 	result = result || rule1.CritOperator != rule2.CritOperator
 	result = result || rule1.Query != rule2.Query
 	result = result || rule1.QueryRefId != rule2.QueryRefId
-	result = result || rule1.Interval != rule2.Interval
+	result = result || rule1.Frequency != rule2.Frequency
 	result = result || rule1.Title != rule2.Title
 	result = result || rule1.Description != rule2.Description
 	result = result || rule1.QueryRange != rule2.QueryRange

+ 1 - 1
pkg/services/sqlstore/alert_rule_changes_test.go

@@ -30,7 +30,7 @@ func TestAlertRuleChangesDataAccess(t *testing.T) {
 					CritLevel:    50,
 					WarnOperator: ">",
 					CritOperator: ">",
-					Interval:     "10",
+					Frequency:    10,
 					Title:        "Alerting title",
 					Description:  "Alerting description",
 					QueryRange:   3600,

+ 3 - 3
pkg/services/sqlstore/alert_rule_test.go

@@ -25,7 +25,7 @@ func TestAlertingDataAccess(t *testing.T) {
 				CritLevel:    50,
 				WarnOperator: ">",
 				CritOperator: ">",
-				Interval:     "10",
+				Frequency:    10,
 				Title:        "Alerting title",
 				Description:  "Alerting description",
 				QueryRange:   3600,
@@ -58,7 +58,7 @@ func TestAlertingDataAccess(t *testing.T) {
 
 			alert := alertQuery.Result[0]
 			So(err2, ShouldBeNil)
-			So(alert.Interval, ShouldEqual, "10")
+			So(alert.Frequency, ShouldEqual, 10)
 			So(alert.WarnLevel, ShouldEqual, 30)
 			So(alert.CritLevel, ShouldEqual, 50)
 			So(alert.WarnOperator, ShouldEqual, ">")
@@ -188,7 +188,7 @@ func TestAlertingDataAccess(t *testing.T) {
 					CritLevel:    50,
 					WarnOperator: ">",
 					CritOperator: ">",
-					Interval:     "10",
+					Frequency:    10,
 					Title:        "Alerting title",
 					Description:  "Alerting description",
 					QueryRange:   3600,

+ 1 - 1
pkg/services/sqlstore/alert_state_test.go

@@ -24,7 +24,7 @@ func TestAlertingStateAccess(t *testing.T) {
 				CritLevel:    50,
 				WarnOperator: ">",
 				CritOperator: ">",
-				Interval:     "10",
+				Frequency:    10,
 				Title:        "Alerting title",
 				Description:  "Alerting description",
 				QueryRange:   3600,

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

@@ -20,7 +20,6 @@ func addAlertMigrations(mg *Migrator) {
 			{Name: "warn_operator", Type: DB_NVarchar, Length: 10, Nullable: false},
 			{Name: "crit_level", Type: DB_BigInt, Nullable: false},
 			{Name: "crit_operator", Type: DB_NVarchar, Length: 10, Nullable: false},
-			{Name: "interval", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "frequency", Type: DB_BigInt, Nullable: false},
 			{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},