mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): add migration for create and update
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/login"
|
"github.com/grafana/grafana/pkg/login"
|
||||||
"github.com/grafana/grafana/pkg/metrics"
|
"github.com/grafana/grafana/pkg/metrics"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/services/alerting"
|
//"github.com/grafana/grafana/pkg/services/alerting"
|
||||||
"github.com/grafana/grafana/pkg/services/eventpublisher"
|
"github.com/grafana/grafana/pkg/services/eventpublisher"
|
||||||
"github.com/grafana/grafana/pkg/services/notifications"
|
"github.com/grafana/grafana/pkg/services/notifications"
|
||||||
"github.com/grafana/grafana/pkg/services/search"
|
"github.com/grafana/grafana/pkg/services/search"
|
||||||
@@ -65,7 +65,7 @@ func main() {
|
|||||||
social.NewOAuthService()
|
social.NewOAuthService()
|
||||||
eventpublisher.Init()
|
eventpublisher.Init()
|
||||||
plugins.Init()
|
plugins.Init()
|
||||||
alerting.Init()
|
//alerting.Init()
|
||||||
|
|
||||||
if err := notifications.Init(); err != nil {
|
if err := notifications.Init(); err != nil {
|
||||||
log.Fatal(3, "Notification service failed to initialize", err)
|
log.Fatal(3, "Notification service failed to initialize", err)
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AlertRule struct {
|
type AlertRule struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
OrgId int64 `json:"-"`
|
OrgId int64 `json:"-"`
|
||||||
DataSourceId int64 `json:"datasourceId"`
|
//DataSourceId int64 `json:"datasourceId"`
|
||||||
DashboardId int64 `json:"dashboardId"`
|
DashboardId int64 `json:"dashboardId"`
|
||||||
PanelId int64 `json:"panelId"`
|
PanelId int64 `json:"panelId"`
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
@@ -19,12 +19,12 @@ type AlertRule struct {
|
|||||||
WarnOperator string `json:"warnOperator"`
|
WarnOperator string `json:"warnOperator"`
|
||||||
CritOperator string `json:"critOperator"`
|
CritOperator string `json:"critOperator"`
|
||||||
Interval string `json:"interval"`
|
Interval string `json:"interval"`
|
||||||
Frequency int64 `json:"frequency"`
|
//Frequency int64 `json:"frequency"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
QueryRange string `json:"queryRange"`
|
QueryRange string `json:"queryRange"`
|
||||||
Aggregator string `json:"aggregator"`
|
Aggregator string `json:"aggregator"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
|
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
Updated time.Time `json:"updated"`
|
Updated time.Time `json:"updated"`
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ func init() {
|
|||||||
func GetAlertById(query *m.GetAlertByIdQuery) error {
|
func GetAlertById(query *m.GetAlertByIdQuery) error {
|
||||||
alert := m.AlertRule{}
|
alert := m.AlertRule{}
|
||||||
has, err := x.Id(query.Id).Get(&alert)
|
has, err := x.Id(query.Id).Get(&alert)
|
||||||
|
|
||||||
if !has {
|
if !has {
|
||||||
return fmt.Errorf("could not find alert")
|
return fmt.Errorf("could not find alert")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ func addAlertMigrations(mg *Migrator) {
|
|||||||
{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},
|
{Name: "aggregator", 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: "created", Type: DB_DateTime, Nullable: false},
|
||||||
|
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user