mirror of
https://github.com/grafana/grafana.git
synced 2025-09-22 18:59:41 +08:00
Merge branch 'alerting' into alerting_notifications
This commit is contained in:
@ -16,6 +16,7 @@ type Alert struct {
|
|||||||
State string
|
State string
|
||||||
Handler int64
|
Handler int64
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
Frequency int64
|
||||||
|
|
||||||
Created time.Time
|
Created time.Time
|
||||||
Updated time.Time
|
Updated time.Time
|
||||||
|
@ -78,6 +78,7 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
|
|||||||
Handler: jsonAlert.Get("handler").MustInt64(),
|
Handler: jsonAlert.Get("handler").MustInt64(),
|
||||||
Enabled: jsonAlert.Get("enabled").MustBool(),
|
Enabled: jsonAlert.Get("enabled").MustBool(),
|
||||||
Description: jsonAlert.Get("description").MustString(),
|
Description: jsonAlert.Get("description").MustString(),
|
||||||
|
Frequency: getTimeDurationStringToSeconds(jsonAlert.Get("frequency").MustString()),
|
||||||
}
|
}
|
||||||
|
|
||||||
valueQuery := jsonAlert.Get("query")
|
valueQuery := jsonAlert.Get("query")
|
||||||
|
@ -215,6 +215,11 @@ func TestAlertRuleExtraction(t *testing.T) {
|
|||||||
So(alerts[1].Handler, ShouldEqual, 0)
|
So(alerts[1].Handler, ShouldEqual, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("should extract frequency in seconds", func() {
|
||||||
|
So(alerts[0].Frequency, ShouldEqual, 60)
|
||||||
|
So(alerts[1].Frequency, ShouldEqual, 60)
|
||||||
|
})
|
||||||
|
|
||||||
Convey("should extract panel idc", func() {
|
Convey("should extract panel idc", func() {
|
||||||
So(alerts[0].PanelId, ShouldEqual, 3)
|
So(alerts[0].PanelId, ShouldEqual, 3)
|
||||||
So(alerts[1].PanelId, ShouldEqual, 4)
|
So(alerts[1].PanelId, ShouldEqual, 4)
|
||||||
|
@ -22,6 +22,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
Name: "Alerting title",
|
Name: "Alerting title",
|
||||||
Description: "Alerting description",
|
Description: "Alerting description",
|
||||||
Settings: simplejson.New(),
|
Settings: simplejson.New(),
|
||||||
|
Frequency: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
So(alert.Name, ShouldEqual, "Alerting title")
|
So(alert.Name, ShouldEqual, "Alerting title")
|
||||||
So(alert.Description, ShouldEqual, "Alerting description")
|
So(alert.Description, ShouldEqual, "Alerting description")
|
||||||
So(alert.State, ShouldEqual, "OK")
|
So(alert.State, ShouldEqual, "OK")
|
||||||
|
So(alert.Frequency, ShouldEqual, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("Alerts with same dashboard id and panel id should update", func() {
|
Convey("Alerts with same dashboard id and panel id should update", func() {
|
||||||
|
@ -17,6 +17,7 @@ func addAlertMigrations(mg *Migrator) {
|
|||||||
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
|
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||||
{Name: "state", Type: DB_NVarchar, Length: 255, Nullable: false},
|
{Name: "state", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||||
{Name: "settings", Type: DB_Text, Nullable: false},
|
{Name: "settings", Type: DB_Text, Nullable: false},
|
||||||
|
{Name: "frequency", Type: DB_BigInt, Nullable: false},
|
||||||
{Name: "handler", Type: DB_BigInt, Nullable: false},
|
{Name: "handler", Type: DB_BigInt, Nullable: false},
|
||||||
{Name: "enabled", Type: DB_Bool, Nullable: false},
|
{Name: "enabled", Type: DB_Bool, Nullable: false},
|
||||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||||
|
Reference in New Issue
Block a user