mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 21:42:38 +08:00
feat(alerting): enabled by default. configurable elert engine
closes #6210
This commit is contained in:
@ -405,7 +405,8 @@ global_session = -1
|
|||||||
# \______(_______;;;)__;;;)
|
# \______(_______;;;)__;;;)
|
||||||
|
|
||||||
[alerting]
|
[alerting]
|
||||||
enabled = true
|
# Makes it possible to turn off alert rule execution.
|
||||||
|
execute_alerts = true
|
||||||
|
|
||||||
#################################### Internal Grafana Metrics ############
|
#################################### Internal Grafana Metrics ############
|
||||||
# Metrics available at HTTP API Url /api/metrics
|
# Metrics available at HTTP API Url /api/metrics
|
||||||
|
@ -355,7 +355,8 @@
|
|||||||
# \______(_______;;;)__;;;)
|
# \______(_______;;;)__;;;)
|
||||||
|
|
||||||
[alerting]
|
[alerting]
|
||||||
;enabled = false
|
# Makes it possible to turn off alert rule execution.
|
||||||
|
;execute_alerts = true
|
||||||
|
|
||||||
#################################### Internal Grafana Metrics ##########################
|
#################################### Internal Grafana Metrics ##########################
|
||||||
# Metrics available at HTTP API Url /api/metrics
|
# Metrics available at HTTP API Url /api/metrics
|
||||||
|
@ -153,16 +153,14 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
|
|||||||
return ApiError(500, "Failed to save dashboard", err)
|
return ApiError(500, "Failed to save dashboard", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if setting.AlertingEnabled {
|
alertCmd := alerting.UpdateDashboardAlertsCommand{
|
||||||
alertCmd := alerting.UpdateDashboardAlertsCommand{
|
OrgId: c.OrgId,
|
||||||
OrgId: c.OrgId,
|
UserId: c.UserId,
|
||||||
UserId: c.UserId,
|
Dashboard: cmd.Result,
|
||||||
Dashboard: cmd.Result,
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if err := bus.Dispatch(&alertCmd); err != nil {
|
if err := bus.Dispatch(&alertCmd); err != nil {
|
||||||
return ApiError(500, "Failed to save alerts", err)
|
return ApiError(500, "Failed to save alerts", err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.TimeRequest(metrics.M_Api_Dashboard_Save)
|
c.TimeRequest(metrics.M_Api_Dashboard_Save)
|
||||||
|
@ -145,7 +145,6 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
|
|||||||
"hasUpdate": plugins.GrafanaHasUpdate,
|
"hasUpdate": plugins.GrafanaHasUpdate,
|
||||||
"env": setting.Env,
|
"env": setting.Env,
|
||||||
},
|
},
|
||||||
"alertingEnabled": setting.AlertingEnabled,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonObj, nil
|
return jsonObj, nil
|
||||||
|
@ -102,7 +102,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
|
|||||||
Children: dashboardChildNavs,
|
Children: dashboardChildNavs,
|
||||||
})
|
})
|
||||||
|
|
||||||
if setting.AlertingEnabled && (c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR) {
|
if c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR {
|
||||||
alertChildNavs := []*dtos.NavLink{
|
alertChildNavs := []*dtos.NavLink{
|
||||||
{Text: "Alert List", Url: setting.AppSubUrl + "/alerting/list"},
|
{Text: "Alert List", Url: setting.AppSubUrl + "/alerting/list"},
|
||||||
{Text: "Notifications", Url: setting.AppSubUrl + "/alerting/notifications"},
|
{Text: "Notifications", Url: setting.AppSubUrl + "/alerting/notifications"},
|
||||||
|
@ -59,7 +59,7 @@ func (g *GrafanaServerImpl) Start() {
|
|||||||
plugins.Init()
|
plugins.Init()
|
||||||
|
|
||||||
// init alerting
|
// init alerting
|
||||||
if setting.AlertingEnabled {
|
if setting.ExecuteAlerts {
|
||||||
engine := alerting.NewEngine()
|
engine := alerting.NewEngine()
|
||||||
g.childRoutines.Go(func() error { return engine.Run(g.context) })
|
g.childRoutines.Go(func() error { return engine.Run(g.context) })
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ var (
|
|||||||
Quota QuotaSettings
|
Quota QuotaSettings
|
||||||
|
|
||||||
// Alerting
|
// Alerting
|
||||||
AlertingEnabled bool
|
ExecuteAlerts bool
|
||||||
|
|
||||||
// logger
|
// logger
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
@ -555,7 +555,7 @@ func NewConfigContext(args *CommandLineArgs) error {
|
|||||||
LdapAllowSignup = ldapSec.Key("allow_sign_up").MustBool(true)
|
LdapAllowSignup = ldapSec.Key("allow_sign_up").MustBool(true)
|
||||||
|
|
||||||
alerting := Cfg.Section("alerting")
|
alerting := Cfg.Section("alerting")
|
||||||
AlertingEnabled = alerting.Key("enabled").MustBool(false)
|
ExecuteAlerts = alerting.Key("execute_alerts").MustBool(true)
|
||||||
|
|
||||||
readSessionConfig()
|
readSessionConfig()
|
||||||
readSmtpSettings()
|
readSmtpSettings()
|
||||||
|
@ -133,10 +133,8 @@ class GraphCtrl extends MetricsPanelCtrl {
|
|||||||
this.addEditorTab('Axes', axesEditorComponent, 2);
|
this.addEditorTab('Axes', axesEditorComponent, 2);
|
||||||
this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3);
|
this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3);
|
||||||
this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html', 4);
|
this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html', 4);
|
||||||
|
this.addEditorTab('Alert', alertTab, 5);
|
||||||
|
|
||||||
if (config.alertingEnabled) {
|
|
||||||
this.addEditorTab('Alert', alertTab, 5);
|
|
||||||
}
|
|
||||||
this.subTabIndex = 0;
|
this.subTabIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user