Skip to content

Commit 04f417a

Browse files
committed
feat(alerting): enabled by default. configurable elert engine
closes grafana#6210
1 parent 9184819 commit 04f417a

File tree

8 files changed

+16
-19
lines changed

8 files changed

+16
-19
lines changed

conf/defaults.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ global_session = -1
405405
# \______(_______;;;)__;;;)
406406

407407
[alerting]
408-
enabled = true
408+
# Makes it possible to turn off alert rule execution.
409+
execute_alerts = true
409410

410411
#################################### Internal Grafana Metrics ############
411412
# Metrics available at HTTP API Url /api/metrics

conf/sample.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@
355355
# \______(_______;;;)__;;;)
356356

357357
[alerting]
358-
;enabled = false
358+
# Makes it possible to turn off alert rule execution.
359+
;execute_alerts = true
359360

360361
#################################### Internal Grafana Metrics ##########################
361362
# Metrics available at HTTP API Url /api/metrics

pkg/api/dashboard.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,14 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
153153
return ApiError(500, "Failed to save dashboard", err)
154154
}
155155

156-
if setting.AlertingEnabled {
157-
alertCmd := alerting.UpdateDashboardAlertsCommand{
158-
OrgId: c.OrgId,
159-
UserId: c.UserId,
160-
Dashboard: cmd.Result,
161-
}
156+
alertCmd := alerting.UpdateDashboardAlertsCommand{
157+
OrgId: c.OrgId,
158+
UserId: c.UserId,
159+
Dashboard: cmd.Result,
160+
}
162161

163-
if err := bus.Dispatch(&alertCmd); err != nil {
164-
return ApiError(500, "Failed to save alerts", err)
165-
}
162+
if err := bus.Dispatch(&alertCmd); err != nil {
163+
return ApiError(500, "Failed to save alerts", err)
166164
}
167165

168166
c.TimeRequest(metrics.M_Api_Dashboard_Save)

pkg/api/frontendsettings.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
145145
"hasUpdate": plugins.GrafanaHasUpdate,
146146
"env": setting.Env,
147147
},
148-
"alertingEnabled": setting.AlertingEnabled,
149148
}
150149

151150
return jsonObj, nil

pkg/api/index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
102102
Children: dashboardChildNavs,
103103
})
104104

105-
if setting.AlertingEnabled && (c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR) {
105+
if c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR {
106106
alertChildNavs := []*dtos.NavLink{
107107
{Text: "Alert List", Url: setting.AppSubUrl + "/alerting/list"},
108108
{Text: "Notifications", Url: setting.AppSubUrl + "/alerting/notifications"},

pkg/cmd/grafana-server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (g *GrafanaServerImpl) Start() {
5959
plugins.Init()
6060

6161
// init alerting
62-
if setting.AlertingEnabled {
62+
if setting.ExecuteAlerts {
6363
engine := alerting.NewEngine()
6464
g.childRoutines.Go(func() error { return engine.Run(g.context) })
6565
}

pkg/setting/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var (
145145
Quota QuotaSettings
146146

147147
// Alerting
148-
AlertingEnabled bool
148+
ExecuteAlerts bool
149149

150150
// logger
151151
logger log.Logger
@@ -555,7 +555,7 @@ func NewConfigContext(args *CommandLineArgs) error {
555555
LdapAllowSignup = ldapSec.Key("allow_sign_up").MustBool(true)
556556

557557
alerting := Cfg.Section("alerting")
558-
AlertingEnabled = alerting.Key("enabled").MustBool(false)
558+
ExecuteAlerts = alerting.Key("execute_alerts").MustBool(true)
559559

560560
readSessionConfig()
561561
readSmtpSettings()

public/app/plugins/panel/graph/module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,8 @@ class GraphCtrl extends MetricsPanelCtrl {
133133
this.addEditorTab('Axes', axesEditorComponent, 2);
134134
this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3);
135135
this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html', 4);
136+
this.addEditorTab('Alert', alertTab, 5);
136137

137-
if (config.alertingEnabled) {
138-
this.addEditorTab('Alert', alertTab, 5);
139-
}
140138
this.subTabIndex = 0;
141139
}
142140

0 commit comments

Comments
 (0)